aboutsummaryrefslogtreecommitdiffstats
path: root/consensus
diff options
context:
space:
mode:
authorbojie <bojie@dexon.org>2019-01-16 17:08:56 +0800
committerWei-Ning Huang <w@byzantine-lab.io>2019-06-12 17:27:21 +0800
commitb784352b70b012f2a6198558c377ca6807a2dcc2 (patch)
treec1e1e382fa74d375078c95bccc1036fd48d211c3 /consensus
parent4095f8c34043a2418dece4d5affbceffe0ca55da (diff)
downloadgo-tangerine-b784352b70b012f2a6198558c377ca6807a2dcc2.tar
go-tangerine-b784352b70b012f2a6198558c377ca6807a2dcc2.tar.gz
go-tangerine-b784352b70b012f2a6198558c377ca6807a2dcc2.tar.bz2
go-tangerine-b784352b70b012f2a6198558c377ca6807a2dcc2.tar.lz
go-tangerine-b784352b70b012f2a6198558c377ca6807a2dcc2.tar.xz
go-tangerine-b784352b70b012f2a6198558c377ca6807a2dcc2.tar.zst
go-tangerine-b784352b70b012f2a6198558c377ca6807a2dcc2.zip
app: fix reward bug with empty block (#155)
* app: fix reward bug with empty block * make block generation consistent * revert change to dmoment in genesis.json
Diffstat (limited to 'consensus')
-rw-r--r--consensus/dexcon/dexcon.go22
1 files changed, 13 insertions, 9 deletions
diff --git a/consensus/dexcon/dexcon.go b/consensus/dexcon/dexcon.go
index 4480f64cb..33f05f599 100644
--- a/consensus/dexcon/dexcon.go
+++ b/consensus/dexcon/dexcon.go
@@ -143,20 +143,24 @@ func (d *Dexcon) calculateBlockReward(round int64, state *state.StateDB) *big.In
// Finalize implements consensus.Engine, ensuring no uncles are set, nor block
// rewards given, and returns the final block.
func (d *Dexcon) Finalize(chain consensus.ChainReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, uncles []*types.Header, receipts []*types.Receipt) (*types.Block, error) {
- reward := d.calculateBlockReward(int64(header.Round), state)
- state.AddBalance(header.Coinbase, reward)
+ if header.Coinbase == (common.Address{}) {
+ header.Reward = new(big.Int)
+ } else {
+ reward := d.calculateBlockReward(int64(header.Round), state)
+ state.AddBalance(header.Coinbase, reward)
- gs := vm.GovernanceStateHelper{state}
- gs.IncTotalSupply(reward)
+ gs := vm.GovernanceStateHelper{state}
+ gs.IncTotalSupply(reward)
- config := gs.Configuration()
+ config := gs.Configuration()
- // Check if halving checkpoint reached.
- if gs.TotalSupply().Cmp(config.NextHalvingSupply) >= 0 {
- gs.MiningHalved()
+ // Check if halving checkpoint reached.
+ if gs.TotalSupply().Cmp(config.NextHalvingSupply) >= 0 {
+ gs.MiningHalved()
+ }
+ header.Reward = reward
}
- header.Reward = reward
header.Root = state.IntermediateRoot(true)
return types.NewBlock(header, txs, uncles, receipts), nil
}