From 1e9599e88a5d88e0090b0ebddfae756e343e605a Mon Sep 17 00:00:00 2001 From: Determinant Date: Wed, 19 Aug 2020 20:32:18 -0400 Subject: make the basic X-to-C logic work --- consensus/dummy/consensus.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'consensus/dummy/consensus.go') diff --git a/consensus/dummy/consensus.go b/consensus/dummy/consensus.go index 9d8db1e..494e4be 100644 --- a/consensus/dummy/consensus.go +++ b/consensus/dummy/consensus.go @@ -19,7 +19,7 @@ import ( ) type OnFinalizeCallbackType = func(chain consensus.ChainReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, uncles []*types.Header) -type OnFinalizeAndAssembleCallbackType = func(chain consensus.ChainReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, uncles []*types.Header, receipts []*types.Receipt) +type OnFinalizeAndAssembleCallbackType = func(state *state.StateDB, txs []*types.Transaction) ([]byte, error) type OnAPIsCallbackType = func(consensus.ChainReader) []rpc.API type OnExtraStateChangeType = func(block *types.Block, statedb *state.StateDB) error @@ -261,14 +261,19 @@ func (self *DummyEngine) Finalize( func (self *DummyEngine) FinalizeAndAssemble(chain consensus.ChainReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, uncles []*types.Header, receipts []*types.Receipt) (*types.Block, error) { + var extdata []byte if self.cb.OnFinalizeAndAssemble != nil { - self.cb.OnFinalizeAndAssemble(chain, header, state, txs, uncles, receipts) + ret, err := self.cb.OnFinalizeAndAssemble(state, txs) + extdata = ret + if err != nil { + return nil, err + } } // commit the final state root header.Root = state.IntermediateRoot(chain.Config().IsEIP158(header.Number)) // Header seems complete, assemble into a block and return - return types.NewBlock(header, txs, uncles, receipts), nil + return types.NewBlock(header, txs, uncles, receipts, extdata), nil } func (self *DummyEngine) Seal(chain consensus.ChainReader, block *types.Block, results chan<- *types.Block, stop <-chan struct{}) (err error) { -- cgit v1.2.3-70-g09d2