mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 15:16:43 +00:00
core: add sidechain event back, update chain2head event
This commit is contained in:
parent
6f42b5a43e
commit
8bb1e67330
3 changed files with 16 additions and 6 deletions
|
|
@ -293,6 +293,7 @@ type BlockChain struct {
|
||||||
stateSyncData []*types.StateSyncData // State sync data
|
stateSyncData []*types.StateSyncData // State sync data
|
||||||
stateSyncFeed event.Feed // State sync feed
|
stateSyncFeed event.Feed // State sync feed
|
||||||
chain2HeadFeed event.Feed // Reorg/NewHead/Fork data feed
|
chain2HeadFeed event.Feed // Reorg/NewHead/Fork data feed
|
||||||
|
chainSideFeed event.Feed // Side chain data feed (removed from geth but needed in bor)
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewBlockChain returns a fully initialised block chain using information
|
// NewBlockChain returns a fully initialised block chain using information
|
||||||
|
|
@ -621,7 +622,9 @@ func (bc *BlockChain) ProcessBlock(block *types.Block, parent *types.Header) (_
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, 0, nil, 0, err
|
return nil, nil, 0, nil, 0, err
|
||||||
}
|
}
|
||||||
parallelStatedb.SetLogger(bc.logger)
|
// TODO(manav): confirm if not setting logger here affects block-stm or not as it's removed
|
||||||
|
// from upstream
|
||||||
|
// parallelStatedb.SetLogger(bc.logger)
|
||||||
|
|
||||||
processorCount++
|
processorCount++
|
||||||
|
|
||||||
|
|
@ -647,7 +650,6 @@ func (bc *BlockChain) ProcessBlock(block *types.Block, parent *types.Header) (_
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, 0, nil, 0, err
|
return nil, nil, 0, nil, 0, err
|
||||||
}
|
}
|
||||||
statedb.SetLogger(bc.logger)
|
|
||||||
|
|
||||||
processorCount++
|
processorCount++
|
||||||
|
|
||||||
|
|
@ -1995,7 +1997,7 @@ func (bc *BlockChain) writeBlockAndSetHead(block *types.Block, receipts []*types
|
||||||
|
|
||||||
bc.chain2HeadFeed.Send(Chain2HeadEvent{
|
bc.chain2HeadFeed.Send(Chain2HeadEvent{
|
||||||
Type: Chain2HeadForkEvent,
|
Type: Chain2HeadForkEvent,
|
||||||
NewChain: []*types.Block{block},
|
NewChain: []*types.Header{block.Header()},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2242,9 +2244,13 @@ func (bc *BlockChain) insertChain(chain types.Blocks, setHead bool, makeWitness
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
headers := make([]*types.Header, size)
|
||||||
|
for i, block := range canonAccum {
|
||||||
|
headers[i] = block.Header()
|
||||||
|
}
|
||||||
bc.chain2HeadFeed.Send(Chain2HeadEvent{
|
bc.chain2HeadFeed.Send(Chain2HeadEvent{
|
||||||
Type: Chain2HeadCanonicalEvent,
|
Type: Chain2HeadCanonicalEvent,
|
||||||
NewChain: canonAccum,
|
NewChain: headers,
|
||||||
})
|
})
|
||||||
|
|
||||||
canonAccum = canonAccum[:0]
|
canonAccum = canonAccum[:0]
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ var (
|
||||||
|
|
||||||
// For tracking reorgs related information
|
// For tracking reorgs related information
|
||||||
type Chain2HeadEvent struct {
|
type Chain2HeadEvent struct {
|
||||||
NewChain []*types.Block
|
NewChain []*types.Header
|
||||||
OldChain []*types.Block
|
OldChain []*types.Header
|
||||||
Type string
|
Type string
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,10 @@ type ChainEvent struct {
|
||||||
Header *types.Header
|
Header *types.Header
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ChainSideEvent struct {
|
||||||
|
Block *types.Block
|
||||||
|
}
|
||||||
|
|
||||||
type ChainHeadEvent struct {
|
type ChainHeadEvent struct {
|
||||||
Header *types.Header
|
Header *types.Header
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue