diff --git a/bin/monitor.js b/bin/monitor.js index 95f28aa85e1799d4fb90c74eeaf35ebcc1bbd183..303af882e0924853926cf35c7d3e29c9315aea5c 100755 --- a/bin/monitor.js +++ b/bin/monitor.js @@ -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()