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

Upgrading Majority.sol to solidity v0.5

parent 41606381
No related branches found
No related tags found
No related merge requests found
// Robert Martin-Legene <robert@nic.ar> // Robert Martin-Legene <robert@nic.ar>
// vim:syntax:filetype=javascript:ai:sm // vim:syntax:filetype=javascript:ai:sm
pragma solidity ^0.4.24; pragma solidity ^0.5;
// This contract is supposed to maintain a list of accounts authorized // This contract is supposed to maintain a list of accounts authorized
// to control members of "the club" using a majority (n/1+1). // to control members of "the club" using a majority (n/1+1).
...@@ -28,7 +28,9 @@ contract Majority { ...@@ -28,7 +28,9 @@ contract Majority {
constructor() public constructor() public
{ {
voters.push( msg.sender ); // Don't want anyone to find a way to trigger the constructor again.
if ( voters.length == 0 )
voters.push( msg.sender );
} }
// This function is used to know how many voters exist. // This function is used to know how many voters exist.
...@@ -55,7 +57,7 @@ contract Majority { ...@@ -55,7 +57,7 @@ contract Majority {
// Beware that: // Beware that:
// 0 = not found. // 0 = not found.
// 1 = first position in a list (so this is actually the real list position + 1). // 1 = first position in a list (so this is actually the real list position + 1).
function _findAddressInList( address[] haystack, address needle ) private pure returns (uint) function _findAddressInList( address[] memory haystack, address needle ) private pure returns (uint)
{ {
uint i = haystack.length; uint i = haystack.length;
while ( i-- > 0 ) while ( i-- > 0 )
......
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