Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
nucleo
Manage
Activity
Members
Labels
Plan
Issues
4
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
blockchain
nucleo
Commits
ae252b1a
Commit
ae252b1a
authored
4 years ago
by
Robert Martin-Legene
Browse files
Options
Downloads
Patches
Plain Diff
Now properly reuses peers.cache contents
parent
4553ab79
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bin/monitor.js
+13
-10
13 additions, 10 deletions
bin/monitor.js
with
13 additions
and
10 deletions
bin/monitor.js
+
13
−
10
View file @
ae252b1a
...
...
@@ -156,25 +156,24 @@ function gotAdminPeers( err, nodelist )
// Try to connect to a random node if we have very few peers
if
(
nowpeers
.
length
<
5
)
{
var
candidate
new
=
[];
var
candidate
=
[];
// find candidate nodes which we can connect to
// (it comes from peers.cache)
peerscache
.
forEach
(
function
(
acachedpeer
)
{
if
(
// Add "a cached peer" to "candidate new" peers
// if the cached peer is not in the list of current node.
currentnodes
.
find
(
function
(
element
)
{
element
.
info
!=
acachedpeer
}
)
)
// Add "a cached peer" to "candidate" peers
// if the cached peer is not in the list of currently
// connected nodes.
if
(
!
currentnodes
.
includes
(
acachedpeer
)
)
{
candidate
new
.
push
(
acachedpeer
);
candidate
.
push
(
acachedpeer
);
}
}
);
if
(
candidate
new
.
length
>
0
)
if
(
candidate
.
length
>
0
)
{
var
i
=
Math
.
floor
(
Math
.
random
()
*
candidate
new
.
length
);
var
enode
=
candidate
new
[
i
];
var
i
=
Math
.
floor
(
Math
.
random
()
*
candidate
.
length
);
var
enode
=
candidate
[
i
];
console
.
log
(
"
We have
"
+
nowpeers
.
length
...
...
@@ -311,6 +310,10 @@ function unlock()
function
timer
()
{
if
(
bfa
.
sockettype
==
'
ipc
'
&&
!
bfa
.
fs
.
existsSync
(
bfa
.
socketurl
)
)
{
return
;
}
if
(
netid
==
0
)
{
web3
.
eth
.
net
.
getId
()
...
...
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