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
82a8a0e1
Commit
82a8a0e1
authored
8 years ago
by
Cédric Moreau
Browse files
Options
Downloads
Patches
Plain Diff
Also add peers during a synchronization (otherwise the node thinks it is alone)
parent
d089ef47
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/lib/sync.js
+39
-1
39 additions, 1 deletion
app/lib/sync.js
with
39 additions
and
1 deletion
app/lib/sync.js
+
39
−
1
View file @
82a8a0e1
...
@@ -191,8 +191,46 @@ function Synchroniser (server, host, port, conf, interactive) {
...
@@ -191,8 +191,46 @@ function Synchroniser (server, host, port, conf, interactive) {
// Save currency parameters given by root block
// Save currency parameters given by root block
const
rootBlock
=
yield
server
.
dal
.
getBlock
(
0
);
const
rootBlock
=
yield
server
.
dal
.
getBlock
(
0
);
yield
BlockchainService
.
saveParametersForRootBlock
(
rootBlock
);
yield
BlockchainService
.
saveParametersForRootBlock
(
rootBlock
);
server
.
dal
.
blockDAL
.
cleanCache
();
server
.
dal
.
blockDAL
.
cleanCache
();
//=======
// Peers
//=======
if
(
!
nopeers
)
{
watcher
.
writeStatus
(
'
Peers...
'
);
yield
syncPeer
(
node
);
const
merkle
=
yield
dal
.
merkleForPeers
();
const
getPeers
=
Q
.
nbind
(
node
.
network
.
peering
.
peers
.
get
,
node
);
const
json2
=
yield
getPeers
({});
const
rm
=
new
NodesMerkle
(
json2
);
if
(
rm
.
root
()
!=
merkle
.
root
()){
const
leavesToAdd
=
[];
const
json
=
yield
getPeers
({
leaves
:
true
});
_
(
json
.
leaves
).
forEach
((
leaf
)
=>
{
if
(
merkle
.
leaves
().
indexOf
(
leaf
)
==
-
1
){
leavesToAdd
.
push
(
leaf
);
}
});
for
(
const
leaf
of
leavesToAdd
)
{
const
json3
=
yield
getPeers
({
"
leaf
"
:
leaf
});
const
jsonEntry
=
json3
.
leaf
.
value
;
const
sign
=
json3
.
leaf
.
value
.
signature
;
const
entry
=
{};
[
"
version
"
,
"
currency
"
,
"
pubkey
"
,
"
endpoints
"
,
"
block
"
].
forEach
((
key
)
=>
{
entry
[
key
]
=
jsonEntry
[
key
];
});
entry
.
signature
=
sign
;
watcher
.
writeStatus
(
'
Peer
'
+
entry
.
pubkey
);
logger
.
info
(
'
Peer
'
+
entry
.
pubkey
);
yield
PeeringService
.
submitP
(
entry
,
false
,
to
===
undefined
);
}
}
else
{
watcher
.
writeStatus
(
'
Peers already known
'
);
}
}
watcher
.
end
();
that
.
push
({
sync
:
true
});
that
.
push
({
sync
:
true
});
logger
.
info
(
'
Sync finished.
'
);
}
catch
(
err
)
{
}
catch
(
err
)
{
that
.
push
({
sync
:
false
,
msg
:
err
});
that
.
push
({
sync
:
false
,
msg
:
err
});
err
&&
watcher
.
writeStatus
(
err
.
message
||
String
(
err
));
err
&&
watcher
.
writeStatus
(
err
.
message
||
String
(
err
));
...
...
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
register
or
sign in
to comment