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