From 9d06b2c5f3e97e49466da3d5c7cfba9206a2052c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felf=C3=B6ldi=20Zsolt?= Date: Wed, 3 Oct 2018 16:25:25 +0200 Subject: core: use ChainHeadEvent subscription in the chain indexer (#17826) --- core/chain_indexer.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/core/chain_indexer.go b/core/chain_indexer.go index 28dc47668..1adde1fcb 100644 --- a/core/chain_indexer.go +++ b/core/chain_indexer.go @@ -53,14 +53,14 @@ type ChainIndexerChain interface { // CurrentHeader retrieves the latest locally known header. CurrentHeader() *types.Header - // SubscribeChainEvent subscribes to new head header notifications. - SubscribeChainEvent(ch chan<- ChainEvent) event.Subscription + // SubscribeChainHeadEvent subscribes to new head header notifications. + SubscribeChainHeadEvent(ch chan<- ChainHeadEvent) event.Subscription } // ChainIndexer does a post-processing job for equally sized sections of the // canonical chain (like BlooomBits and CHT structures). A ChainIndexer is // connected to the blockchain through the event system by starting a -// ChainEventLoop in a goroutine. +// ChainHeadEventLoop in a goroutine. // // Further child ChainIndexers can be added which use the output of the parent // section indexer. These child indexers receive new head notifications only @@ -142,8 +142,8 @@ func (c *ChainIndexer) AddCheckpoint(section uint64, shead common.Hash) { // cascading background processing. Children do not need to be started, they // are notified about new events by their parents. func (c *ChainIndexer) Start(chain ChainIndexerChain) { - events := make(chan ChainEvent, 10) - sub := chain.SubscribeChainEvent(events) + events := make(chan ChainHeadEvent, 10) + sub := chain.SubscribeChainHeadEvent(events) go c.eventLoop(chain.CurrentHeader(), events, sub) } @@ -190,7 +190,7 @@ func (c *ChainIndexer) Close() error { // eventLoop is a secondary - optional - event loop of the indexer which is only // started for the outermost indexer to push chain head events into a processing // queue. -func (c *ChainIndexer) eventLoop(currentHeader *types.Header, events chan ChainEvent, sub event.Subscription) { +func (c *ChainIndexer) eventLoop(currentHeader *types.Header, events chan ChainHeadEvent, sub event.Subscription) { // Mark the chain indexer as active, requiring an additional teardown atomic.StoreUint32(&c.active, 1) -- cgit v1.2.3