diff --git a/core/blockchain.go b/core/blockchain.go index ae92386dc2..2705ed1349 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -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 diff --git a/core/blockchain_reader.go b/core/blockchain_reader.go index 4894523b0e..e93ff5c33c 100644 --- a/core/blockchain_reader.go +++ b/core/blockchain_reader.go @@ -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) +} diff --git a/eth/api_backend.go b/eth/api_backend.go index 19c835871d..3f826b7861 100644 --- a/eth/api_backend.go +++ b/eth/api_backend.go @@ -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 { diff --git a/eth/backend.go b/eth/backend.go index f90860e936..cae2aabe30 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -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 { diff --git a/eth/catalyst/api.go b/eth/catalyst/api.go index f07aedc024..4fabe95ef3 100644 --- a/eth/catalyst/api.go +++ b/eth/catalyst/api.go @@ -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,