@@ -17,54 +17,69 @@ contract ChainStorage is StorageBase {
1717 /// @dev structure of block that is created for each election
1818 struct Block {
1919 /// @dev shard => root of merkle tree (the winner)
20- mapping (uint256 => bytes32 ) roots;
21- mapping (bytes32 => bool ) uniqueBlindedProposals;
22- mapping (address => Voter) voters;
20+ mapping (uint256 => bytes32 ) roots;
21+ mapping (bytes32 => bool ) uniqueBlindedProposals;
22+ mapping (address => Voter) voters;
2323
2424 /// @dev shard => max votes
25- mapping (uint256 => uint256 ) maxsVotes;
25+ mapping (uint256 => uint256 ) maxsVotes;
2626
2727 // shard => proposal => counts
2828 // Im using mapping, because its less gas consuming that array,
2929 // and also it is much easier to work with mapping than with array
3030 // unfortunately we can't be able to delete this data to release gas, why?
3131 // because to do this, we need to save all the keys and then run loop for all keys... that may cause OOG
3232 // also storing keys is more gas consuming so... I made decision to stay with mapping and never delete history
33- mapping (uint256 => mapping (bytes32 => uint256 )) counts;
33+ mapping (uint256 => mapping (bytes32 => uint256 )) counts;
3434
3535 /// @dev shard => total amount of tokens
36- mapping (uint256 => uint256 ) balancesPerShard;
36+ mapping (uint256 => uint256 ) balancesPerShard;
3737
3838 address [] verifierAddresses;
3939 }
4040
4141 /// @dev blockHeight => Block - results of each elections will be saved here: one block (array element) per election
42- mapping (uint256 => Block) blocks;
42+ mapping (uint256 => Block) blocks;
4343
4444 /// @dev shard => blockHeight
45- mapping (uint256 => uint256 ) public initialBlockHeights;
45+ mapping (uint256 => uint256 ) public initialBlockHeights;
4646
4747 bool public updateMinimumStakingTokenPercentageEnabled;
4848
49- uint8 public blocksPerPhase;
49+ uint8 public blocksPerPropose;
50+ uint8 public blocksPerReveal;
5051
5152 uint8 public minimumStakingTokenPercentage;
5253
53- event LogChainConfig (uint8 blocksPerPhase , uint8 requirePercentOfTokens , bool updateMinimumStakingTokenPercentageEnabled );
54+ event LogChainConfig (
55+ uint8 blocksPerPropose ,
56+ uint8 blocksPerReveal ,
57+ uint8 requirePercentOfTokens ,
58+ bool updateMinimumStakingTokenPercentageEnabled
59+ );
5460
55- constructor (uint8 _blocksPerPhase ,
61+ constructor (
62+ uint8 _blocksPerPropose ,
63+ uint8 _blocksPerReveal ,
5664 uint8 _minimumStakingTokenPercentage ,
5765 bool _updateMinimumStakingTokenPercentageEnabled ) public {
58- require (_blocksPerPhase > 0 , "_blocksPerPhase can't be empty " );
59- blocksPerPhase = _blocksPerPhase;
66+ require (_blocksPerPropose > 0 , "_blocksPerPropose can't be empty " );
67+ require (_blocksPerReveal > 0 , "_blocksPerReveal can't be empty " );
68+ blocksPerPropose = _blocksPerPropose;
69+ blocksPerReveal = _blocksPerReveal;
6070
6171 require (_minimumStakingTokenPercentage > 0 , "_minimumStakingTokenPercentage can't be empty " );
6272 require (_minimumStakingTokenPercentage <= 100 , "_minimumStakingTokenPercentage can't be over 100% " );
6373 minimumStakingTokenPercentage = _minimumStakingTokenPercentage;
6474
6575 updateMinimumStakingTokenPercentageEnabled = _updateMinimumStakingTokenPercentageEnabled;
6676
67- emit LogChainConfig (_blocksPerPhase, _minimumStakingTokenPercentage, _updateMinimumStakingTokenPercentageEnabled);
77+ emit LogChainConfig (
78+ _blocksPerPropose,
79+ _blocksPerReveal,
80+ _minimumStakingTokenPercentage,
81+ _updateMinimumStakingTokenPercentageEnabled
82+ );
6883 }
6984
7085 function getInitialBlockHeight (uint256 _shard ) public view returns (uint256 ) {
@@ -147,7 +162,7 @@ contract ChainStorage is StorageBase {
147162 }
148163
149164 function updateBlockVoter (uint256 _blockHeight , address _voterAddr , bytes32 _blindedProposal , uint256 _shard , uint256 _balance )
150- external onlyFromStorageOwner returns (bool ) {
165+ external onlyFromStorageOwner returns (bool ) {
151166 Voter storage voter = blocks[_blockHeight].voters[_voterAddr];
152167 voter.blindedProposal = _blindedProposal;
153168 voter.shard = _shard;
@@ -170,7 +185,7 @@ contract ChainStorage is StorageBase {
170185 require (_minimumStakingTokenPercentage <= 100 , "_minimumStakingTokenPercentage can't be over 100% " );
171186 minimumStakingTokenPercentage = _minimumStakingTokenPercentage;
172187
173- emit LogChainConfig (blocksPerPhase , _minimumStakingTokenPercentage, true );
188+ emit LogChainConfig (blocksPerPropose, blocksPerReveal , _minimumStakingTokenPercentage, true );
174189
175190 return true ;
176191 }
0 commit comments