Skip to content
Snippets Groups Projects
Commit 7a5a13df authored by Miguel Montes's avatar Miguel Montes
Browse files

Eliminación de mayseal.js

parent 528cde90
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