Skip to content

Commit 3123792

Browse files
committed
netsync: Rename event handler to stall handler.
This renames the event handler goroutine to stallHandler to more accurately reflect its only remaining purpose after all of the recent changes to move everything else out of the event handler. This is a part of the overall effort to convert the code related to handling the various sync manager events to synchronous code that runs in the various caller goroutines.
1 parent 5bafa06 commit 3123792

1 file changed

Lines changed: 8 additions & 10 deletions

File tree

internal/netsync/manager.go

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1991,13 +1991,11 @@ func limitAdd(m map[chainhash.Hash]struct{}, hash chainhash.Hash, limit int) {
19911991
m[hash] = struct{}{}
19921992
}
19931993

1994-
// eventHandler is the main handler for the sync manager. It must be run as a
1995-
// goroutine. It processes block and inv messages in a separate goroutine from
1996-
// the peer handlers so the block (MsgBlock) messages are handled by a single
1997-
// thread without needing to lock memory data structures. This is important
1998-
// because the sync manager controls which blocks are needed and how the
1999-
// fetching should proceed.
2000-
func (m *SyncManager) eventHandler(ctx context.Context) {
1994+
// stallHandler monitors the header sync process to detect stalls and disconnect
1995+
// the sync peer which ensures clean recovery from stalls.
1996+
//
1997+
// It must be run as a goroutine.
1998+
func (m *SyncManager) stallHandler(ctx context.Context) {
20011999
out:
20022000
for {
20032001
select {
@@ -2017,7 +2015,7 @@ out:
20172015
}
20182016
}
20192017

2020-
log.Trace("Sync manager event handler done")
2018+
log.Trace("Sync manager stall handler done")
20212019
}
20222020

20232021
// SyncPeerID returns the ID of the current sync peer, or 0 if there is none.
@@ -2232,11 +2230,11 @@ func (m *SyncManager) IsCurrent() bool {
22322230
func (m *SyncManager) Run(ctx context.Context) {
22332231
log.Trace("Starting sync manager")
22342232

2235-
// Start the event handler goroutine.
2233+
// Start the stall handler goroutine.
22362234
var wg sync.WaitGroup
22372235
wg.Add(1)
22382236
go func() {
2239-
m.eventHandler(ctx)
2237+
m.stallHandler(ctx)
22402238
wg.Done()
22412239
}()
22422240

0 commit comments

Comments
 (0)