core: move newPayloadFeed to Blockchain

This commit is contained in:
MariusVanDerWijden 2025-12-17 12:49:08 +01:00
parent c6c6eb9227
commit 63c4383bd2
5 changed files with 13 additions and 14 deletions

View file

@ -309,6 +309,7 @@ type BlockChain struct {
chainHeadFeed event.Feed
logsFeed event.Feed
blockProcFeed event.Feed
newPayloadFeed event.Feed // Feed for engine API newPayload events
blockProcCounter int32
scope event.SubscriptionScope
genesisBlock *types.Block

View file

@ -522,3 +522,13 @@ func (bc *BlockChain) SubscribeLogsEvent(ch chan<- []*types.Log) event.Subscript
func (bc *BlockChain) SubscribeBlockProcessingEvent(ch chan<- bool) event.Subscription {
return bc.scope.Track(bc.blockProcFeed.Subscribe(ch))
}
// / SubscribeNewPayloadEvent registers a subscription for NewPayloadEvent.
func (bc *BlockChain) SubscribeNewPayloadEvent(ch chan<- NewPayloadEvent) event.Subscription {
return bc.newPayloadFeed.Subscribe(ch)
}
// SendNewPayloadEvent sends a NewPayloadEvent to subscribers.
func (bc *BlockChain) SendNewPayloadEvent(ev NewPayloadEvent) {
bc.newPayloadFeed.Send(ev)
}

View file

@ -317,7 +317,7 @@ func (b *EthAPIBackend) SubscribeChainHeadEvent(ch chan<- core.ChainHeadEvent) e
// SubscribeNewPayloadEvent registers a subscription for NewPayloadEvent.
func (b *EthAPIBackend) SubscribeNewPayloadEvent(ch chan<- core.NewPayloadEvent) event.Subscription {
return b.eth.SubscribeNewPayloadEvent(ch)
return b.eth.BlockChain().SubscribeNewPayloadEvent(ch)
}
func (b *EthAPIBackend) SubscribeLogsEvent(ch chan<- []*types.Log) event.Subscription {

View file

@ -124,8 +124,6 @@ type Ethereum struct {
lock sync.RWMutex // Protects the variadic fields (e.g. gas price and etherbase)
shutdownTracker *shutdowncheck.ShutdownTracker // Tracks if and when the node has shutdown ungracefully
newPayloadFeed event.Feed // Feed for engine API newPayload events
}
// New creates a new Ethereum object (including the initialisation of the common Ethereum object),
@ -430,16 +428,6 @@ func (s *Ethereum) Synced() bool { return s.handler.synced
func (s *Ethereum) SetSynced() { s.handler.enableSyncedFeatures() }
func (s *Ethereum) ArchiveMode() bool { return s.config.NoPruning }
// SubscribeNewPayloadEvent registers a subscription for NewPayloadEvent.
func (s *Ethereum) SubscribeNewPayloadEvent(ch chan<- core.NewPayloadEvent) event.Subscription {
return s.newPayloadFeed.Subscribe(ch)
}
// SendNewPayloadEvent sends a NewPayloadEvent to subscribers.
func (s *Ethereum) SendNewPayloadEvent(ev core.NewPayloadEvent) {
s.newPayloadFeed.Send(ev)
}
// Protocols returns all the currently configured
// network protocols to start.
func (s *Ethereum) Protocols() []p2p.Protocol {

View file

@ -790,7 +790,7 @@ func (api *ConsensusAPI) newPayload(params engine.ExecutableData, versionedHashe
hash := block.Hash()
// Emit NewPayloadEvent for ethstats reporting
api.eth.SendNewPayloadEvent(core.NewPayloadEvent{
api.eth.BlockChain().SendNewPayloadEvent(core.NewPayloadEvent{
Hash: hash,
Number: block.NumberU64(),
ProcessingTime: processingTime,