@@ -3,6 +3,7 @@ pragma solidity ^0.5.4;
33import "../interfaces/IBlockReward.sol " ;
44import "../storage/EternalStorage.sol " ;
55import "./SCurveProvider.sol " ;
6+
67import "../libs/SafeMath.sol " ;
78
89
@@ -18,14 +19,17 @@ contract BlockReward is EternalStorage, SCurveProvider, IBlockReward {
1819 bytes32 internal constant MINTED_FOR_ACCOUNT_IN_BLOCK = "mintedForAccountInBlock " ;
1920 bytes32 internal constant MINTED_IN_BLOCK = "mintedInBlock " ;
2021
21- uint256 public constant COMMUNITY_FUND_AMOUNT = 1 ether ;
22+ // solhint-disable var-name-mixedcase
23+
24+ /// SYSTEM_ADDRESS: 2^160 - 2
2225 address internal SYSTEM_ADDRESS = 0xffffFFFfFFffffffffffffffFfFFFfffFFFfFFfE ;
23- // Needs
24- address public communityFund = 0x0000000000000000000000000000000000000000 ;
25-
26+ /// The constant amount that gets sent to the
27+ /// community fund with each new block. It is a constant
28+ /// value but can be set in the constructor.
29+ uint256 public communityFundAmount;
30+ address public communityFund;
2631 mapping (address => address ) public payoutAddresses;
27-
28- event Rewarded (address [] receivers , uint256 [] rewards );
32+ // solhint-enable var-name-mixedcase
2933
3034 modifier onlySystem {
3135 require (
@@ -43,6 +47,13 @@ contract BlockReward is EternalStorage, SCurveProvider, IBlockReward {
4347 _;
4448 }
4549
50+ constructor (address _communityFundAddress , uint256 _communityFundAmount )
51+ public
52+ {
53+ communityFund = _communityFundAddress;
54+ communityFundAmount = _communityFundAmount;
55+ }
56+
4657 function setCommunityFund (address _newFund )
4758 external
4859 onlyCommunityFund
@@ -82,14 +93,10 @@ contract BlockReward is EternalStorage, SCurveProvider, IBlockReward {
8293 rewards[0 ] = getBlockReward (block .number );
8394
8495 receivers[1 ] = _getPayoutAddress (communityFund);
85- rewards[1 ] = COMMUNITY_FUND_AMOUNT ;
96+ rewards[1 ] = communityFundAmount ;
8697
87- _trackMinted (rewards[0 ], receivers[0 ]);
88- _trackCommunityMinted (rewards[0 ], receivers[1 ]);
89-
90- // We might take this out cause service transactions
91- // cannot emit events
92- emit Rewarded (receivers, rewards);
98+ _logMinted (rewards[0 ], receivers[0 ]);
99+ _logCommunityMinted (rewards[1 ], receivers[1 ]);
93100
94101 return (receivers, rewards);
95102 }
@@ -162,35 +169,35 @@ contract BlockReward is EternalStorage, SCurveProvider, IBlockReward {
162169 return _payoutAddress;
163170 }
164171
165- function _trackCommunityMinted (uint256 _amount , address _account )
172+ function _logCommunityMinted (uint256 _amount , address _account )
166173 private
167174 {
168- bytes32 hash ;
175+ bytes32 _hash ;
169176
170- hash = MINTED_FOR_COMMUNITY;
171- uintStorage[hash ] = uintStorage[hash ].add (_amount);
177+ _hash = MINTED_FOR_COMMUNITY;
178+ uintStorage[_hash ] = uintStorage[_hash ].add (_amount);
172179
173- hash = keccak256 (abi.encode (MINTED_FOR_COMMUNITY_FOR_ACCOUNT, _account));
174- uintStorage[hash ] = uintStorage[hash ].add (_amount);
180+ _hash = keccak256 (abi.encode (MINTED_FOR_COMMUNITY_FOR_ACCOUNT, _account));
181+ uintStorage[_hash ] = uintStorage[_hash ].add (_amount);
175182
176- _trackMinted (_amount, _account);
183+ _logMinted (_amount, _account);
177184 }
178185
179- function _trackMinted (uint256 _amount , address _account )
186+ function _logMinted (uint256 _amount , address _account )
180187 private
181188 {
182- bytes32 hash ;
189+ bytes32 _hash ;
183190
184- hash = keccak256 (abi.encode (MINTED_FOR_ACCOUNT_IN_BLOCK, _account, block .number ));
185- uintStorage[hash ] = _amount;
191+ _hash = keccak256 (abi.encode (MINTED_FOR_ACCOUNT_IN_BLOCK, _account, block .number ));
192+ uintStorage[_hash ] = uintStorage[_hash]. add ( _amount) ;
186193
187- hash = keccak256 (abi.encode (MINTED_FOR_ACCOUNT, _account));
188- uintStorage[hash ] = uintStorage[hash ].add (_amount);
194+ _hash = keccak256 (abi.encode (MINTED_FOR_ACCOUNT, _account));
195+ uintStorage[_hash ] = uintStorage[_hash ].add (_amount);
189196
190- hash = keccak256 (abi.encode (MINTED_IN_BLOCK, block .number ));
191- uintStorage[hash ] = uintStorage[hash ].add (_amount);
197+ _hash = keccak256 (abi.encode (MINTED_IN_BLOCK, block .number ));
198+ uintStorage[_hash ] = uintStorage[_hash ].add (_amount);
192199
193- hash = MINTED_TOTALLY;
194- uintStorage[hash ] = uintStorage[hash ].add (_amount);
200+ _hash = MINTED_TOTALLY;
201+ uintStorage[_hash ] = uintStorage[_hash ].add (_amount);
195202 }
196203}
0 commit comments