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

monitor.js will keep trying to unlock locked keys, using an empty passphrase.

parent a10f02d8
No related branches found
No related tags found
No related merge requests found
...@@ -7,13 +7,7 @@ ...@@ -7,13 +7,7 @@
const Libbfa = require( process.env.BFAHOME + '/bin/libbfa.js'); const Libbfa = require( process.env.BFAHOME + '/bin/libbfa.js');
var bfa = new Libbfa(); var bfa = new Libbfa();
var web3 = bfa.newweb3(); var web3 = bfa.newweb3();
var lastUnlock = 0;
function pluralEnglish( num, single, plural )
{
if ( num == 1 )
return single;
return plural;
}
function peerlist() function peerlist()
{ {
...@@ -89,7 +83,7 @@ function peerlist() ...@@ -89,7 +83,7 @@ function peerlist()
console.log( console.log(
"We have " "We have "
+ nowpeers.length + nowpeers.length
+ " peer" + pluralEnglish(nowpeers.length,'','s') + ", so will try to connect to " + " peer" + ( nowpeers.length==1 ? '' : 's' ) + ", so will try to connect to "
+ enode + enode
); );
web3.eth.bfaAdminaddPeer( enode ); web3.eth.bfaAdminaddPeer( enode );
...@@ -167,10 +161,51 @@ function mayseal() ...@@ -167,10 +161,51 @@ function mayseal()
); );
} }
function unlock()
{
var now = new Date();
if ( lastUnlock + 600 > now )
return;
lastUnlock = now;
web3.eth.personal.bfalistWallets()
.then(
function pushone(x)
{
var i = x.length;
var wallets = new Array();
while ( i-- > 0 )
if ( x[i].status == "Locked" )
wallets.push( x[i] );
i = wallets.length;
if ( i == 0 )
return;
var promises = new Array();
while ( i-- > 0 )
{
var j = wallets[i].accounts.length;
while ( j-- > 0 )
{
var addr = wallets[i].accounts[j].address;
var promise =
web3.eth.personal.unlockAccount( addr, "", 0 )
.catch( error => { } );
promises.push( promise );
}
}
}
,
function err(x)
{
// we don't care?
}
)
}
function timer() function timer()
{ {
peerlist(); peerlist();
mayseal(); mayseal();
unlock();
} }
peerlist(); peerlist();
......
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