mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-22 04:36:42 +00:00
core: move newPayloadFeed to Blockchain
This commit is contained in:
parent
c6c6eb9227
commit
63c4383bd2
5 changed files with 13 additions and 14 deletions
|
|
@ -309,6 +309,7 @@ type BlockChain struct {
|
||||||
chainHeadFeed event.Feed
|
chainHeadFeed event.Feed
|
||||||
logsFeed event.Feed
|
logsFeed event.Feed
|
||||||
blockProcFeed event.Feed
|
blockProcFeed event.Feed
|
||||||
|
newPayloadFeed event.Feed // Feed for engine API newPayload events
|
||||||
blockProcCounter int32
|
blockProcCounter int32
|
||||||
scope event.SubscriptionScope
|
scope event.SubscriptionScope
|
||||||
genesisBlock *types.Block
|
genesisBlock *types.Block
|
||||||
|
|
|
||||||
|
|
@ -522,3 +522,13 @@ func (bc *BlockChain) SubscribeLogsEvent(ch chan<- []*types.Log) event.Subscript
|
||||||
func (bc *BlockChain) SubscribeBlockProcessingEvent(ch chan<- bool) event.Subscription {
|
func (bc *BlockChain) SubscribeBlockProcessingEvent(ch chan<- bool) event.Subscription {
|
||||||
return bc.scope.Track(bc.blockProcFeed.Subscribe(ch))
|
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)
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -317,7 +317,7 @@ func (b *EthAPIBackend) SubscribeChainHeadEvent(ch chan<- core.ChainHeadEvent) e
|
||||||
|
|
||||||
// SubscribeNewPayloadEvent registers a subscription for NewPayloadEvent.
|
// SubscribeNewPayloadEvent registers a subscription for NewPayloadEvent.
|
||||||
func (b *EthAPIBackend) SubscribeNewPayloadEvent(ch chan<- core.NewPayloadEvent) event.Subscription {
|
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 {
|
func (b *EthAPIBackend) SubscribeLogsEvent(ch chan<- []*types.Log) event.Subscription {
|
||||||
|
|
|
||||||
|
|
@ -124,8 +124,6 @@ type Ethereum struct {
|
||||||
lock sync.RWMutex // Protects the variadic fields (e.g. gas price and etherbase)
|
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
|
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),
|
// 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) SetSynced() { s.handler.enableSyncedFeatures() }
|
||||||
func (s *Ethereum) ArchiveMode() bool { return s.config.NoPruning }
|
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
|
// Protocols returns all the currently configured
|
||||||
// network protocols to start.
|
// network protocols to start.
|
||||||
func (s *Ethereum) Protocols() []p2p.Protocol {
|
func (s *Ethereum) Protocols() []p2p.Protocol {
|
||||||
|
|
|
||||||
|
|
@ -790,7 +790,7 @@ func (api *ConsensusAPI) newPayload(params engine.ExecutableData, versionedHashe
|
||||||
hash := block.Hash()
|
hash := block.Hash()
|
||||||
|
|
||||||
// Emit NewPayloadEvent for ethstats reporting
|
// Emit NewPayloadEvent for ethstats reporting
|
||||||
api.eth.SendNewPayloadEvent(core.NewPayloadEvent{
|
api.eth.BlockChain().SendNewPayloadEvent(core.NewPayloadEvent{
|
||||||
Hash: hash,
|
Hash: hash,
|
||||||
Number: block.NumberU64(),
|
Number: block.NumberU64(),
|
||||||
ProcessingTime: processingTime,
|
ProcessingTime: processingTime,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue