Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@AnthonyAkentiev
Last active July 26, 2018 09:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AnthonyAkentiev/70514ff9904dff873ac3ac14f6fda5f0 to your computer and use it in GitHub Desktop.
Save AnthonyAkentiev/70514ff9904dff873ac3ac14f6fda5f0 to your computer and use it in GitHub Desktop.
// 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