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

Better error handling + new startup script

parent 23b83d95
No related branches found
No related tags found
No related merge requests found
...@@ -96,11 +96,16 @@ module.exports = class Libbfa ...@@ -96,11 +96,16 @@ module.exports = class Libbfa
body: body, body: body,
callback: function RPCresponse( err, obj ) callback: function RPCresponse( err, obj )
{ {
var r;
var e;
if ( err ) if ( err )
throw new Error( err ); e = err;
else
if ( obj.body.error && obj.body.error.code && obj.body.error.message ) if ( obj.body.error && obj.body.error.code && obj.body.error.message )
throw new Error( 'Error ' + obj.body.error.code + ": "+ obj.body.error.message ); e = 'Error ' + obj.body.error.code + ": "+ obj.body.error.message;
callback(obj.body.result); else
r = obj.body.result;
callback(e, r);
} }
}); });
}; };
......
...@@ -120,13 +120,15 @@ function parsenode( node ) ...@@ -120,13 +120,15 @@ function parsenode( node )
return n; return n;
} }
function gotAdminPeers( nodelist ) function gotAdminPeers( err, nodelist )
{ {
var nowpeers = []; var nowpeers = [];
var peerscache = readPeersCache(); var peerscache = readPeersCache();
var newoutpeers = []; var newoutpeers = [];
var currentnodes = []; var currentnodes = [];
if ( err )
return;
// The nodelist also contains peers which are not yet validated // The nodelist also contains peers which are not yet validated
// if they even belong to this network. Parsenode returns an // if they even belong to this network. Parsenode returns an
// object or nothing, based on our criteria // object or nothing, based on our criteria
...@@ -208,8 +210,9 @@ function mayseal() ...@@ -208,8 +210,9 @@ function mayseal()
// Get a list of clique.getSigners, so we can see if we are // Get a list of clique.getSigners, so we can see if we are
// in the list of authorized sealers. // in the list of authorized sealers.
web3.bfa.clique.getSigners( web3.bfa.clique.getSigners(
function gotListOfSealers(x) function gotListOfSealers(e,x)
{ {
if (e) return;
var lcsealers = x.map( name => name.toLowerCase() ); var lcsealers = x.map( name => name.toLowerCase() );
var isSigner = (lcsealers.indexOf(me) > -1); var isSigner = (lcsealers.indexOf(me) > -1);
if ( isSigner ) if ( isSigner )
...@@ -245,8 +248,9 @@ function unlock() ...@@ -245,8 +248,9 @@ function unlock()
return; return;
var unlockedsomething = false; var unlockedsomething = false;
web3.bfa.personal.listWallets( web3.bfa.personal.listWallets(
function pushone(x) function pushone(e,x)
{ {
if (e) return;
var i = x.length; var i = x.length;
var wallets = new Array(); var wallets = new Array();
while ( i-- > 0 ) while ( i-- > 0 )
...@@ -302,7 +306,16 @@ function unlock() ...@@ -302,7 +306,16 @@ function unlock()
function timer() function timer()
{ {
if ( netid == 0 ) if ( netid == 0 )
web3.eth.net.getId().then( x => {netid = x} ); {
web3.eth.net.getId()
.then( x => {
netid = x;
} )
.catch( err => {
console.log("monitor.js non-fatal: "+err)
});
return;
}
peerlist(); peerlist();
mayseal(); mayseal();
unlock(); unlock();
......
...@@ -48,7 +48,7 @@ unset LOGDIR LOGPIPE PIDLIST ...@@ -48,7 +48,7 @@ unset LOGDIR LOGPIPE PIDLIST
echo "*** Setting up logging." echo "*** Setting up logging."
# Clean up logging # Clean up logging
LOGDIR=$( mktemp --directory ) LOGDIR=$( mktemp -d )
trap "rm -f ${LOGDIR}" EXIT trap "rm -f ${LOGDIR}" EXIT
LOGPIPE=${LOGDIR}/logpipe LOGPIPE=${LOGDIR}/logpipe
mknod ${LOGPIPE} p mknod ${LOGPIPE} p
......
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