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
b847974b
Commit
b847974b
authored
5 years ago
by
Robert Martin-Legene
Browse files
Options
Downloads
Patches
Plain Diff
Documentacion y una funcion nueva (setTimeout)
parent
ac9b1e34
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/Majority/Majority.sol
+9
-1
9 additions, 1 deletion
src/Majority/Majority.sol
src/Majority/README.md
+99
-0
99 additions, 0 deletions
src/Majority/README.md
with
108 additions
and
1 deletion
src/Majority/Majority.sol
+
9
−
1
View file @
b847974b
...
...
@@ -29,11 +29,19 @@ contract Majority {
constructor( uint timeout ) public
{
if ( timeout >
0 )
if ( timeout >
= 360
0 )
votetimeout = timeout;
council.push( address(msg.sender) );
}
function setTimeout( uint timeout ) public
{
if ( ! isCouncil(msg.sender) )
revert("Only council members may use this function.");
if ( timeout >= 3600 )
votetimeout = timeout;
}
function councilLength() public view returns (uint)
{
return council.length;
...
...
This diff is collapsed.
Click to expand it.
src/Majority/README.md
0 → 100644
+
99
−
0
View file @
b847974b
# Majority
This contract maintains a list of accounts authorized
to control members of "the club" using a majority (n/1+1).
We call that group the "council".
For instance, could be useful for
*
a list of sealers
*
a board of directors
*
a local chess club
*
even outsourcing this kind of management from another smart contract.
There are a few functions that can be used to see the contents of the
data structures used. Usually, you probably only need to
**vote()**
and
to ask if some account
**isCouncil()**
See the test suite for examples of how to extract information from the
different datastructures, if you feel you really need that.
## Events
### voteCast
**voteCast( address voter, address victim, bool promotion )**
Gives the address of who voted, who they voted for and if it should
be a promotion (true) or demotion (false).
A promotion means to become a member of the council.
A demotion means to be removed from the list of council members.
### adminChange
**adminChange( address admin, bool promotion )**
This event is emitted when an address has received enough votes to be
promoted or demoted and that action is taken.
## Functions
### constructor
**constructor( uint timeout )**
This function is called when the contract is getting deployed.
The deploying address automatically becomes the only council member and
needs to vote to include other's. The contract creator has no special
powers other than other council members, and as such can be voted out
and lose all control over the contract.
If you specify an integer when deploying the contract, you can change
the time it takes for a vote to time out. The timeout can not be set
lower than one hour. The default is 7 days.
### setTimeout
**setTimeout( uint )**
Change the timeout (in seconds) for validity of votes cast.
Any council member can change the timeout.
The timeout can not be set lower than one hour.
### councilLength
**councilLength()**
Returns a uint telling how many entries are in the council list.
### votesLength
**votesLength()**
Returns a uint telling how many structs are in the votes array.
### isCouncil
**isCouncil( address subject )**
Returns true or false whether the given address is a member of the
council.
### mayVote
**mayVote( address voter, address victim, bool promotion )**
Returns true or false if a certain address may vote a certain vote for
a certain address.
### vote
**vote( address victim, bool promotion )**
Performs actual voting on including (true) or removing (false) an address
from the council.
If the final member of the council votes to remove itself, the contract
will self-destruct.
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