Skip to content

Commit

Permalink
consensus: refactor FinalizeAndAssemble to use Finalize (#21993)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mr-Leshiy authored Dec 11, 2020
1 parent efe6dd2 commit c49aae9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
5 changes: 2 additions & 3 deletions consensus/clique/clique.go
Original file line number Diff line number Diff line change
Expand Up @@ -561,9 +561,8 @@ func (c *Clique) Finalize(chain consensus.ChainHeaderReader, header *types.Heade
// FinalizeAndAssemble implements consensus.Engine, ensuring no uncles are set,
// nor block rewards given, and returns the final block.
func (c *Clique) FinalizeAndAssemble(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, uncles []*types.Header, receipts []*types.Receipt) (*types.Block, error) {
// No block rewards in PoA, so the state remains as is and uncles are dropped
header.Root = state.IntermediateRoot(chain.Config().IsEIP158(header.Number))
header.UncleHash = types.CalcUncleHash(nil)
// Finalize block
c.Finalize(chain, header, state, txs, uncles)

// Assemble and return the final block for sealing
return types.NewBlock(header, txs, nil, receipts, new(trie.Trie)), nil
Expand Down
5 changes: 2 additions & 3 deletions consensus/ethash/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -584,9 +584,8 @@ func (ethash *Ethash) Finalize(chain consensus.ChainHeaderReader, header *types.
// FinalizeAndAssemble implements consensus.Engine, accumulating the block and
// uncle rewards, setting the final state and assembling the block.
func (ethash *Ethash) FinalizeAndAssemble(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, uncles []*types.Header, receipts []*types.Receipt) (*types.Block, error) {
// Accumulate any block and uncle rewards and commit the final state root
accumulateRewards(chain.Config(), state, header, uncles)
header.Root = state.IntermediateRoot(chain.Config().IsEIP158(header.Number))
// Finalize block
ethash.Finalize(chain, header, state, txs, uncles)

// Header seems complete, assemble into a block and return
return types.NewBlock(header, txs, uncles, receipts, new(trie.Trie)), nil
Expand Down

0 comments on commit c49aae9

Please sign in to comment.