Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
9d06b2c5
Commit
9d06b2c5
authored
6 years ago
by
Felföldi Zsolt
Committed by
Péter Szilágyi
6 years ago
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: use ChainHeadEvent subscription in the chain indexer (#17826)
parent
e5677114
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
6 deletions
+6
-6
chain_indexer.go
core/chain_indexer.go
+6
-6
No files found.
core/chain_indexer.go
View file @
9d06b2c5
...
...
@@ -53,14 +53,14 @@ type ChainIndexerChain interface {
// CurrentHeader retrieves the latest locally known header.
CurrentHeader
()
*
types
.
Header
// SubscribeChainEvent subscribes to new head header notifications.
SubscribeChain
Event
(
ch
chan
<-
Chain
Event
)
event
.
Subscription
// SubscribeChain
Head
Event subscribes to new head header notifications.
SubscribeChain
HeadEvent
(
ch
chan
<-
ChainHead
Event
)
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.
// Chain
Head
EventLoop 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
Chain
Head
Event
,
10
)
sub
:=
chain
.
SubscribeChain
Head
Event
(
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
Chain
Head
Event
,
sub
event
.
Subscription
)
{
// Mark the chain indexer as active, requiring an additional teardown
atomic
.
StoreUint32
(
&
c
.
active
,
1
)
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment