analyseether/ether_sql

Add rewards in the state_diff table

Closed this issue · 0 comments

Is your feature request related to a problem? Please describe.
After every block rewards are given to the corresponding miners and uncles of the block. Currently there is no method to keep track of these rewards in the state_diff table.

Describe the solution you'd like
This feature depends on the prerequisite #19,
and is strongly linked the current state table, since to get the value_from column we need the state of the miner in the last block.

Sample code to calculate miner reward (to be included in the method add_block_number)

rewards_wei = constants.PreByzantiniumReward
        if temp_block_number > constants.FORK_BLOCK_NUMBER['Byzantium']:
            rewards_wei = constants.PostByzantiniumReward

Sample code to calculate uncle reward (to be included in the method add_block_number)

                rewards_wei = constants.PreByzantiniumReward
                if temp_block_number > constants.FORK_BLOCK_NUMBER['Byzantium']:
                    rewards_wei = constants.PostByzantiniumReward
                factor = (int(temp_uncle['uncle_blocknumber']) + 8 - int(temp_uncle['current_blocknumber']))/8.0
                logging.debug('uncle_blocknumber: {}, current_blocknumber: {}'. \
                                format(temp_uncle['uncle_blocknumber'],
                                       temp_uncle['current_blocknumber']))
                to = temp_uncle['miner']
                reward_wei = int(factor*constants.PreByzantiniumReward)
                if temp_block_number > constants.FORK_BLOCK_NUMBER['Byzantium']:
                    rewards_wei = int(factor*constants.PostByzantiniumReward)