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

Esto ya es parte del monitor.js

parent 163d506c
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/node
// vim:syntax:filetype=javascript:ai:sm
// vim:expandtab:backspace=indent,eol,start:softtabstop=4
"use strict"
const Libbfa = require( process.env.BFAHOME + '/bin/libbfa.js');
function mayseal()
{
var bfa = new Libbfa();
var web3 = bfa.newweb3();
var me = web3.eth.defaultAccount.toLowerCase();
web3.eth.isMining().then( function(isMining){
web3.eth.getSigners().then( function(x){
var lcsealers = x.map( name => name.toLowerCase() );
// console.log( "Miners are:\n\t" + lcsealers.join("\n\t") );
var isSigner = (lcsealers.indexOf(me) > -1);
var sealerfile = bfa.nodedir + '/miner';
var not = "not ";
if ( isSigner )
not = "";
console.log( "Account " + me + " is " + not + "allowed to seal." );
if ( isSigner )
{
if ( ! bfa.fs.existsSync( sealerfile ) )
{
var fd = bfa.fs.openSync( sealerfile, 'a' );
bfa.fs.close( fd );
console.log( "Created 'sealer' file " + sealerfile );
}
if ( ! isMining )
{
web3.eth.minerstart();
console.log( 'Started to seal.' );
}
else
{
console.log( "You are already sealing. All is well." );
}
}
else
{
if ( bfa.fs.existsSync( sealerfile ) )
{
bfa.fs.unlinkSync( sealerfile );
console.log( "Deleted 'sealer' file " + sealerfile );
}
if ( isMining )
{
web3.eth.minerstop();
console.log( 'I was trying to seal, but am not authorized. Stopped trying.' );
}
else
{
console.log( "I wasn't trying to seal anyway. All is well." );
}
}
});
},function(x){
console.log(x);
process.exit(1);
})
}
mayseal();
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