Skip to content

Commit 4819a6e

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 f31e049 commit 4819a6e

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
@@ -1989,13 +1989,11 @@ func limitAdd(m map[chainhash.Hash]struct{}, hash chainhash.Hash, limit int) {
19891989
m[hash] = struct{}{}
19901990
}
19911991

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

2018-
log.Trace("Sync manager event handler done")
2016+
log.Trace("Sync manager stall handler done")
20192017
}
20202018

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

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

0 commit comments

Comments
 (0)