Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
nucleo
Manage
Activity
Members
Labels
Plan
Issues
4
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
blockchain
nucleo
Commits
2253f6de
Commit
2253f6de
authored
6 years ago
by
Robert Martin-Legene
Browse files
Options
Downloads
Patches
Plain Diff
Minor optimizations
parent
554c7754
No related branches found
Branches containing commit
No related tags found
1 merge request
!1
Distillery
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
.gitignore
+1
-0
1 addition, 0 deletions
.gitignore
bin/compile.and.deploy.contract
+1
-1
1 addition, 1 deletion
bin/compile.and.deploy.contract
bin/libbfa.js
+4
-3
4 additions, 3 deletions
bin/libbfa.js
src/Sealers.sol
+8
-12
8 additions, 12 deletions
src/Sealers.sol
with
14 additions
and
16 deletions
.gitignore
+
1
−
0
View file @
2253f6de
...
@@ -3,3 +3,4 @@
...
@@ -3,3 +3,4 @@
*/status
*/status
cache
cache
*/cache
*/cache
network5445/contracts/*
This diff is collapsed.
Click to expand it.
bin/compile.and.deploy.contract
+
1
−
1
View file @
2253f6de
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
bin/libbfa.js
+
4
−
3
View file @
2253f6de
...
@@ -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
);
...
...
This diff is collapsed.
Click to expand it.
src/Sealers.sol
+
8
−
12
View file @
2253f6de
...
@@ -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[] p
ublic
sealers;
address[] p
rivate
sealers;
Proposal[] p
ublic
sealerproposals;
Proposal[] p
rivate
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
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment