From d165c250ccf7913108db083fdde3e3d58697c175 Mon Sep 17 00:00:00 2001 From: Robert Martin-Legene <robert@nic.ar> Date: Mon, 10 Jun 2019 17:02:23 -0300 Subject: [PATCH] Upgrading Majority.sol to solidity v0.5 --- src/Majority.sol | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Majority.sol b/src/Majority.sol index 71a5515..07fafc2 100644 --- a/src/Majority.sol +++ b/src/Majority.sol @@ -1,7 +1,7 @@ // Robert Martin-Legene <robert@nic.ar> // 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 // to control members of "the club" using a majority (n/1+1). @@ -28,7 +28,9 @@ contract Majority { 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. @@ -55,7 +57,7 @@ contract Majority { // Beware that: // 0 = not found. // 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; while ( i-- > 0 ) -- GitLab