Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
duniter
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nodes
typescript
duniter
Commits
31b62d6a
Commit
31b62d6a
authored
Jun 10, 2018
by
Cédric Moreau
Browse files
Options
Downloads
Patches
Plain Diff
[enh] sync: usage of `--nopeers` and `--nosbx`
parent
8544f1ff
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
app/lib/common-libs/programOptions.ts
+4
-0
4 additions, 0 deletions
app/lib/common-libs/programOptions.ts
app/modules/crawler/index.ts
+3
-3
3 additions, 3 deletions
app/modules/crawler/index.ts
app/modules/crawler/lib/sync.ts
+18
-13
18 additions, 13 deletions
app/modules/crawler/lib/sync.ts
with
25 additions
and
16 deletions
app/lib/common-libs/programOptions.ts
+
4
−
0
View file @
31b62d6a
...
@@ -17,6 +17,8 @@ export interface ProgramOptions {
...
@@ -17,6 +17,8 @@ export interface ProgramOptions {
mdb
?:
string
mdb
?:
string
home
?:
string
home
?:
string
notrim
?:
boolean
notrim
?:
boolean
nosbx
?:
boolean
nopeers
?:
boolean
syncTrace
?:
string
syncTrace
?:
string
}
}
...
@@ -24,5 +26,7 @@ export const cliprogram: ProgramOptions = {
...
@@ -24,5 +26,7 @@ export const cliprogram: ProgramOptions = {
mdb
:
opts
.
mdb
,
mdb
:
opts
.
mdb
,
home
:
opts
.
home
,
home
:
opts
.
home
,
notrim
:
opts
.
notrim
,
notrim
:
opts
.
notrim
,
nosbx
:
opts
.
nosbx
,
nopeers
:
opts
.
nopeers
,
syncTrace
:
opts
[
'
sync-trace
'
],
syncTrace
:
opts
[
'
sync-trace
'
],
}
}
This diff is collapsed.
Click to expand it.
app/modules/crawler/index.ts
+
3
−
3
View file @
31b62d6a
...
@@ -65,6 +65,7 @@ export const CrawlerDependency = {
...
@@ -65,6 +65,7 @@ export const CrawlerDependency = {
{
value
:
'
--nocautious
'
,
desc
:
'
Do not check blocks validity during sync.
'
},
{
value
:
'
--nocautious
'
,
desc
:
'
Do not check blocks validity during sync.
'
},
{
value
:
'
--cautious
'
,
desc
:
'
Check blocks validity during sync (overrides --nocautious option).
'
},
{
value
:
'
--cautious
'
,
desc
:
'
Check blocks validity during sync (overrides --nocautious option).
'
},
{
value
:
'
--nopeers
'
,
desc
:
'
Do not retrieve peers during sync.
'
},
{
value
:
'
--nopeers
'
,
desc
:
'
Do not retrieve peers during sync.
'
},
{
value
:
'
--nosbx
'
,
desc
:
'
Do not retrieve sandboxes during sync.
'
},
{
value
:
'
--onlypeers
'
,
desc
:
'
Will only try to sync peers.
'
},
{
value
:
'
--onlypeers
'
,
desc
:
'
Will only try to sync peers.
'
},
{
value
:
'
--slow
'
,
desc
:
'
Download slowly the blokchcain (for low connnections).
'
},
{
value
:
'
--slow
'
,
desc
:
'
Download slowly the blokchcain (for low connnections).
'
},
{
value
:
'
--readfilesystem
'
,
desc
:
'
Also read the filesystem to speed up block downloading.
'
},
{
value
:
'
--readfilesystem
'
,
desc
:
'
Also read the filesystem to speed up block downloading.
'
},
...
@@ -98,7 +99,6 @@ export const CrawlerDependency = {
...
@@ -98,7 +99,6 @@ export const CrawlerDependency = {
const
chunkLength
=
0
;
const
chunkLength
=
0
;
const
interactive
=
!
program
.
nointeractive
;
const
interactive
=
!
program
.
nointeractive
;
const
askedCautious
=
cautious
;
const
askedCautious
=
cautious
;
const
nopeers
=
program
.
nopeers
;
const
noShufflePeers
=
program
.
noshuffle
;
const
noShufflePeers
=
program
.
noshuffle
;
let
otherDAL
=
undefined
let
otherDAL
=
undefined
...
@@ -112,9 +112,9 @@ export const CrawlerDependency = {
...
@@ -112,9 +112,9 @@ export const CrawlerDependency = {
const
remote
=
new
Synchroniser
(
server
,
onHost
,
onPort
,
interactive
===
true
,
program
.
slow
===
true
,
otherDAL
);
const
remote
=
new
Synchroniser
(
server
,
onHost
,
onPort
,
interactive
===
true
,
program
.
slow
===
true
,
otherDAL
);
if
(
program
.
onlypeers
===
true
)
{
if
(
program
.
onlypeers
===
true
)
{
return
remote
.
syncPeers
(
nopeers
,
true
,
onHost
,
onPort
)
return
remote
.
syncPeers
(
true
,
onHost
,
onPort
)
}
else
{
}
else
{
return
remote
.
sync
(
upTo
,
chunkLength
,
askedCautious
,
nopeers
,
noShufflePeers
===
true
)
return
remote
.
sync
(
upTo
,
chunkLength
,
askedCautious
,
noShufflePeers
===
true
)
}
}
}
}
},
{
},
{
...
...
This diff is collapsed.
Click to expand it.
app/modules/crawler/lib/sync.ts
+
18
−
13
View file @
31b62d6a
...
@@ -34,6 +34,7 @@ import {CommonConstants} from "../../../lib/common-libs/constants"
...
@@ -34,6 +34,7 @@ import {CommonConstants} from "../../../lib/common-libs/constants"
import
{
Underscore
}
from
"
../../../lib/common-libs/underscore
"
import
{
Underscore
}
from
"
../../../lib/common-libs/underscore
"
import
{
HttpMerkleOfPeers
}
from
"
../../bma/lib/dtos
"
import
{
HttpMerkleOfPeers
}
from
"
../../bma/lib/dtos
"
import
{
DBPeer
,
JSONDBPeer
}
from
"
../../../lib/db/DBPeer
"
import
{
DBPeer
,
JSONDBPeer
}
from
"
../../../lib/db/DBPeer
"
import
{
cliprogram
}
from
"
../../../lib/common-libs/programOptions
"
const
multimeter
=
require
(
'
multimeter
'
);
const
multimeter
=
require
(
'
multimeter
'
);
const
makeQuerablePromise
=
require
(
'
querablep
'
);
const
makeQuerablePromise
=
require
(
'
querablep
'
);
...
@@ -131,7 +132,7 @@ export class Synchroniser extends stream.Duplex {
...
@@ -131,7 +132,7 @@ export class Synchroniser extends stream.Duplex {
return
node
.
getCurrent
();
return
node
.
getCurrent
();
}
}
async
sync
(
to
:
number
,
chunkLen
:
number
,
askedCautious
=
false
,
nopeers
=
false
,
noShufflePeers
=
false
)
{
async
sync
(
to
:
number
,
chunkLen
:
number
,
askedCautious
=
false
,
noShufflePeers
=
false
)
{
try
{
try
{
...
@@ -164,7 +165,7 @@ export class Synchroniser extends stream.Duplex {
...
@@ -164,7 +165,7 @@ export class Synchroniser extends stream.Duplex {
// Peers (just for P2P download)
// Peers (just for P2P download)
//=======
//=======
let
peers
:(
JSONDBPeer
|
null
)[]
=
[];
let
peers
:(
JSONDBPeer
|
null
)[]
=
[];
if
(
!
nopeers
&&
(
to
-
localNumber
>
1000
))
{
// P2P download if more than 1000 blocs
if
(
!
cliprogram
.
nopeers
&&
(
to
-
localNumber
>
1000
))
{
// P2P download if more than 1000 blocs
this
.
watcher
.
writeStatus
(
'
Peers...
'
);
this
.
watcher
.
writeStatus
(
'
Peers...
'
);
const
merkle
=
await
this
.
dal
.
merkleForPeers
();
const
merkle
=
await
this
.
dal
.
merkleForPeers
();
const
getPeers
:(
params
:
any
)
=>
Promise
<
HttpMerkleOfPeers
>
=
node
.
getPeers
.
bind
(
node
);
const
getPeers
:(
params
:
any
)
=>
Promise
<
HttpMerkleOfPeers
>
=
node
.
getPeers
.
bind
(
node
);
...
@@ -320,16 +321,20 @@ export class Synchroniser extends stream.Duplex {
...
@@ -320,16 +321,20 @@ export class Synchroniser extends stream.Duplex {
await
this
.
BlockchainService
.
saveParametersForRootBlock
(
BlockDTO
.
fromJSONObject
(
rootBlock
))
await
this
.
BlockchainService
.
saveParametersForRootBlock
(
BlockDTO
.
fromJSONObject
(
rootBlock
))
this
.
server
.
dal
.
blockDAL
.
cleanCache
();
this
.
server
.
dal
.
blockDAL
.
cleanCache
();
if
(
!
cliprogram
.
nosbx
)
{
//=======
//=======
// Sandboxes
// Sandboxes
//=======
//=======
this
.
watcher
.
writeStatus
(
'
Synchronizing the sandboxes...
'
);
this
.
watcher
.
writeStatus
(
'
Synchronizing the sandboxes...
'
);
await
pullSandboxToLocalServer
(
this
.
conf
.
currency
,
node
,
this
.
server
,
this
.
server
.
logger
,
this
.
watcher
,
1
,
false
)
await
pullSandboxToLocalServer
(
this
.
conf
.
currency
,
node
,
this
.
server
,
this
.
server
.
logger
,
this
.
watcher
,
1
,
false
)
}
if
(
!
cliprogram
.
nopeers
)
{
//=======
//=======
// Peers
// Peers
//=======
//=======
await
this
.
syncPeers
(
nopeers
,
fullSync
,
this
.
host
,
this
.
port
,
to
)
await
this
.
syncPeers
(
fullSync
,
this
.
host
,
this
.
port
,
to
)
}
// Trim the loki data
// Trim the loki data
await
this
.
server
.
dal
.
loki
.
flushAndTrimData
()
await
this
.
server
.
dal
.
loki
.
flushAndTrimData
()
...
@@ -345,8 +350,8 @@ export class Synchroniser extends stream.Duplex {
...
@@ -345,8 +350,8 @@ export class Synchroniser extends stream.Duplex {
}
}
}
}
async
syncPeers
(
nopeers
:
boolean
,
fullSync
:
boolean
,
host
:
string
,
port
:
number
,
to
?:
number
)
{
async
syncPeers
(
fullSync
:
boolean
,
host
:
string
,
port
:
number
,
to
?:
number
)
{
if
(
!
nopeers
&&
fullSync
)
{
if
(
!
cliprogram
.
nopeers
&&
fullSync
)
{
const
peering
=
await
Contacter
.
fetchPeer
(
host
,
port
,
this
.
contacterOptions
);
const
peering
=
await
Contacter
.
fetchPeer
(
host
,
port
,
this
.
contacterOptions
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment