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