Created
July 23, 2021 07:08
-
-
Save percybolmer/1484ae52a20bb89557d8d2d3efcdcf8d to your computer and use it in GitHub Desktop.
Method to add stakeholder
This file contains hidden or 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
/** | |
* @notice _addStakeholder takes care of adding a stakeholder to the stakeholders array | |
*/ | |
function _addStakeholder(address staker) internal returns (uint256){ | |
// Push a empty item to the Array to make space for our new stakeholder | |
stakeholders.push(); | |
// Calculate the index of the last item in the array by Len-1 | |
uint256 userIndex = stakeholders.length - 1; | |
// Assign the address to the new index | |
stakeholders[userIndex].user = staker; | |
// Add index to the stakeHolders | |
stakes[staker] = userIndex; | |
return userIndex; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment