diff options
author | Determinant <[email protected]> | 2020-08-03 17:16:53 -0400 |
---|---|---|
committer | Determinant <[email protected]> | 2020-08-03 17:16:53 -0400 |
commit | c73ba009031126e16da6999468851b33f93e8005 (patch) | |
tree | 961111c84794cf3807946d073bcef36ec8ba6025 /consensus | |
parent | 746a107e2a7bb1f66049240d320e29d0a0536eae (diff) |
allow using extra binary data in a block for state transition
Diffstat (limited to 'consensus')
-rw-r--r-- | consensus/clique/clique.go | 4 | ||||
-rw-r--r-- | consensus/consensus.go | 2 | ||||
-rw-r--r-- | consensus/dummy/consensus.go | 9 | ||||
-rw-r--r-- | consensus/ethash/consensus.go | 4 |
4 files changed, 19 insertions, 0 deletions
diff --git a/consensus/clique/clique.go b/consensus/clique/clique.go index c97e198..d3ad1d9 100644 --- a/consensus/clique/clique.go +++ b/consensus/clique/clique.go @@ -736,3 +736,7 @@ func encodeSigHeader(w io.Writer, header *types.Header) { panic("can't encode: " + err.Error()) } } + +func (c *Clique) ExtraStateChange(_ *types.Block, _ *state.StateDB) error { + return nil +} diff --git a/consensus/consensus.go b/consensus/consensus.go index 93fc9dc..603a3e9 100644 --- a/consensus/consensus.go +++ b/consensus/consensus.go @@ -114,6 +114,8 @@ type Engine interface { // Close terminates any background threads maintained by the consensus engine. Close() error + + ExtraStateChange(block *types.Block, statedb *state.StateDB) error } // PoW is a consensus engine based on proof-of-work. diff --git a/consensus/dummy/consensus.go b/consensus/dummy/consensus.go index adc85fe..9d8db1e 100644 --- a/consensus/dummy/consensus.go +++ b/consensus/dummy/consensus.go @@ -21,6 +21,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 OnAPIsCallbackType = func(consensus.ChainReader) []rpc.API +type OnExtraStateChangeType = func(block *types.Block, statedb *state.StateDB) error type ConsensusCallbacks struct { OnSeal func(*types.Block) error @@ -28,6 +29,7 @@ type ConsensusCallbacks struct { OnAPIs OnAPIsCallbackType OnFinalize OnFinalizeCallbackType OnFinalizeAndAssemble OnFinalizeAndAssembleCallbackType + OnExtraStateChange OnExtraStateChangeType } type DummyEngine struct { @@ -322,3 +324,10 @@ func (self *DummyEngine) APIs(chain consensus.ChainReader) (res []rpc.API) { func (self *DummyEngine) Close() error { return nil } + +func (self *DummyEngine) ExtraStateChange(block *types.Block, statedb *state.StateDB) error { + if self.cb.OnExtraStateChange != nil { + return self.cb.OnExtraStateChange(block, statedb) + } + return nil +} diff --git a/consensus/ethash/consensus.go b/consensus/ethash/consensus.go index d9130ec..c325eea 100644 --- a/consensus/ethash/consensus.go +++ b/consensus/ethash/consensus.go @@ -635,3 +635,7 @@ func accumulateRewards(config *params.ChainConfig, state *state.StateDB, header } state.AddBalance(header.Coinbase, reward) } + +func (ethash *Ethash) ExtraStateChange(_ *types.Block, _ *state.StateDB) error { + return nil +} |