Skip to content
Snippets Groups Projects
Commit ae252b1a authored by Robert Martin-Legene's avatar Robert Martin-Legene
Browse files

Now properly reuses peers.cache contents

parent 4553ab79
No related branches found
No related tags found
No related merge requests found
......@@ -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 candidatenew = [];
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 ) )
{
candidatenew.push( acachedpeer );
candidate.push( acachedpeer );
}
}
);
if ( candidatenew.length > 0 )
if ( candidate.length > 0 )
{
var i = Math.floor( Math.random() * candidatenew.length );
var enode = candidatenew[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()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment