mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 15:16:43 +00:00
Fix: resolve comments
This commit is contained in:
parent
ae38eea1f3
commit
722e246d07
4 changed files with 21 additions and 13 deletions
|
|
@ -679,13 +679,14 @@ func (c *Bor) Finalize(chain consensus.ChainReader, header *types.Header, state
|
||||||
// No block rewards in PoA, so the state remains as is and uncles are dropped
|
// 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.Root = state.IntermediateRoot(chain.Config().IsEIP158(header.Number))
|
||||||
header.UncleHash = types.CalcUncleHash(nil)
|
header.UncleHash = types.CalcUncleHash(nil)
|
||||||
r := chain.(*core.BlockChain)
|
bc := chain.(*core.BlockChain)
|
||||||
r.SetStateSync(stateSyncData)
|
bc.SetStateSync(stateSyncData)
|
||||||
}
|
}
|
||||||
|
|
||||||
// FinalizeAndAssemble implements consensus.Engine, ensuring no uncles are set,
|
// FinalizeAndAssemble implements consensus.Engine, ensuring no uncles are set,
|
||||||
// nor block rewards given, and returns the final block.
|
// nor block rewards given, and returns the final block.
|
||||||
func (c *Bor) FinalizeAndAssemble(chain consensus.ChainReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, uncles []*types.Header, receipts []*types.Receipt) (*types.Block, error) {
|
func (c *Bor) FinalizeAndAssemble(chain consensus.ChainReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, uncles []*types.Header, receipts []*types.Receipt) (*types.Block, error) {
|
||||||
|
stateSyncData := []*types.StateData{}
|
||||||
headerNumber := header.Number.Uint64()
|
headerNumber := header.Number.Uint64()
|
||||||
if headerNumber%c.config.Sprint == 0 {
|
if headerNumber%c.config.Sprint == 0 {
|
||||||
cx := chainContext{Chain: chain, Bor: c}
|
cx := chainContext{Chain: chain, Bor: c}
|
||||||
|
|
@ -699,7 +700,7 @@ func (c *Bor) FinalizeAndAssemble(chain consensus.ChainReader, header *types.Hea
|
||||||
|
|
||||||
if !c.WithoutHeimdall {
|
if !c.WithoutHeimdall {
|
||||||
// commit statees
|
// commit statees
|
||||||
_, err = c.CommitStates(state, header, cx)
|
stateSyncData, err = c.CommitStates(state, header, cx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("Error while committing states", "error", err)
|
log.Error("Error while committing states", "error", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
@ -713,7 +714,8 @@ func (c *Bor) FinalizeAndAssemble(chain consensus.ChainReader, header *types.Hea
|
||||||
|
|
||||||
// Assemble block
|
// Assemble block
|
||||||
block := types.NewBlock(header, txs, nil, receipts)
|
block := types.NewBlock(header, txs, nil, receipts)
|
||||||
|
bc := chain.(*core.BlockChain)
|
||||||
|
bc.SetStateSync(stateSyncData)
|
||||||
// return the final block for sealing
|
// return the final block for sealing
|
||||||
return block, nil
|
return block, nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -335,7 +335,7 @@ func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, chainConfig *par
|
||||||
return bc, nil
|
return bc, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetStateSync set sync data in block
|
// SetStateSync set sync data in state_data
|
||||||
func (bc *BlockChain) SetStateSync(stateData []*types.StateData) {
|
func (bc *BlockChain) SetStateSync(stateData []*types.StateData) {
|
||||||
bc.stateSyncData = stateData
|
bc.stateSyncData = stateData
|
||||||
}
|
}
|
||||||
|
|
@ -1548,6 +1548,9 @@ func (bc *BlockChain) writeBlockWithState(block *types.Block, receipts []*types.
|
||||||
// event here.
|
// event here.
|
||||||
if emitHeadEvent {
|
if emitHeadEvent {
|
||||||
bc.chainHeadFeed.Send(ChainHeadEvent{Block: block})
|
bc.chainHeadFeed.Send(ChainHeadEvent{Block: block})
|
||||||
|
for _, data := range bc.stateSyncData {
|
||||||
|
bc.stateSyncFeed.Send(StateSyncEvent{StateData: data})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
bc.chainSideFeed.Send(ChainSideEvent{Block: block})
|
bc.chainSideFeed.Send(ChainSideEvent{Block: block})
|
||||||
|
|
|
||||||
|
|
@ -66,14 +66,6 @@ func (n *BlockNonce) UnmarshalText(input []byte) error {
|
||||||
return hexutil.UnmarshalFixedText("BlockNonce", input, n[:])
|
return hexutil.UnmarshalFixedText("BlockNonce", input, n[:])
|
||||||
}
|
}
|
||||||
|
|
||||||
// StateData represents state received from Ethereum Blockchain
|
|
||||||
type StateData struct {
|
|
||||||
Did uint64
|
|
||||||
Contract common.Address
|
|
||||||
Data string
|
|
||||||
TxHash common.Hash
|
|
||||||
}
|
|
||||||
|
|
||||||
//go:generate gencodec -type Header -field-override headerMarshaling -out gen_header_json.go
|
//go:generate gencodec -type Header -field-override headerMarshaling -out gen_header_json.go
|
||||||
|
|
||||||
// Header represents a block header in the Ethereum blockchain.
|
// Header represents a block header in the Ethereum blockchain.
|
||||||
|
|
|
||||||
11
core/types/state_data.go
Normal file
11
core/types/state_data.go
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
package types
|
||||||
|
|
||||||
|
import "github.com/maticnetwork/bor/common"
|
||||||
|
|
||||||
|
// StateData represents state received from Ethereum Blockchain
|
||||||
|
type StateData struct {
|
||||||
|
Did uint64
|
||||||
|
Contract common.Address
|
||||||
|
Data string
|
||||||
|
TxHash common.Hash
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue