Last active
July 26, 2018 09:23
-
-
Save AnthonyAkentiev/70514ff9904dff873ac3ac14f6fda5f0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// WRITE | |
function transfer(address _to, uint256 _value) public returns (bool) { | |
updateCopyOnWriteMap(msg.sender, _to); | |
return super.transfer(_to, _value); | |
} | |
function updateCopyOnWriteMap(address _from, address _to) internal { | |
if(!isDataInMapping(_from)){ | |
balancesAtTheStartOfVoting[_for].balance = balances[_for]; | |
} | |
if(!isDataInMapping(_to)){ | |
balancesAtTheStartOfVoting[_to].balance = balances[_to]; | |
} | |
} | |
// READ | |
function getBalance(address _for) public vire returns(uint256){ | |
return balances[_for]; | |
} | |
function getBalanceAtEventStart(address _for) public view returns(uint256){ | |
if (isDataInMapping(_for)) { | |
return balancesAtTheStartOfVoting[_for].balance; | |
} | |
return balances[_for]; | |
} | |
function isDataInMapping(address _for) internal view returns(bool) { | |
// TODO | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment