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

Minor optimizations

parent 554c7754
No related branches found
No related tags found
1 merge request!1Distillery
......@@ -3,3 +3,4 @@
*/status
cache
*/cache
network5445/contracts/*
......@@ -32,7 +32,7 @@ var address = rcpt.contractAddress
var pubcontract = mycontract.at(address)
console.log( pubcontract.address )
EOT
echo '*** Creating contract. This will take at least 16 seconds.'
echo '*** Creating contract. Please stand by.'
outfile=$( mktemp )
cleanup "$outfile"
geth_exec_file $js > $outfile
......
......@@ -125,9 +125,10 @@ module.exports = class Libbfa
var contractaddress = this.fs.realpathSync( contractdir ).replace(/^.*\//, '');
if ( contractaddress == undefined )
return;
var abi = JSON.parse(
this.fs.readFileSync( contractdir + '/abi' ).toString()
);
var abistr = this.fs.readFileSync( contractdir + '/abi' ).toString();
if ( abistr == undefined )
return;
var abi = JSON.parse( abistr );
if ( abi == undefined )
return;
var c = new w3.eth.Contract( abi, contractaddress );
......
......@@ -13,16 +13,16 @@ contract Sealers {
struct Proposal {
address victim; // Whom are we voting about.
uint votestart; // In which block did this vote begin?
bool promotion; // true=promotion, false=demotion
address[] voters; // List of voters.
bool promotion; // true=promotion, false=demotion
address[] voters; // List of voters.
}
address[] public sealers;
Proposal[] public sealerproposals;
address[] private sealers;
Proposal[] private sealerproposals;
event voteCast( address voter, address victim, bool promotionOrDemotion );
event adminChange( address admin, bool promotionOrDemotion );
constructor() public
constructor() public
{
sealers.push( msg.sender );
}
......@@ -47,11 +47,6 @@ contract Sealers {
return ( _findAddressInList( sealers, subject ) > 0 );
}
function requireSealer( address subject ) public view
{
require( isSealer(subject), "Not sealer" );
}
// Returns an index to the position of the needle inside haystack.
// Beware that:
// 0 = not found.
......@@ -197,12 +192,13 @@ contract Sealers {
// Is already Sealer and want to promote him?
// Can't promote someone who is already a sealer.
if ( isSealer(victim) && promotion )
bool victimSealer = isSealer( victim );
if ( victimSealer && promotion )
return false;
// Is not Sealer and want to demote him?
// Can't demote someone who is not a sealer.
if ( !isSealer(victim) && !promotion )
if ( !victimSealer && !promotion )
return false;
// See if the voter is already in the list of voters for this [victim,promotion] tuple
......
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