Skip to content

Commit fea3cc0

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 cd4b69d commit fea3cc0

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

internal/netsync/manager.go

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

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

2019-
log.Trace("Sync manager event handler done")
2017+
log.Trace("Sync manager stall handler done")
20202018
}
20212019

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

2234-
// Start the event handler goroutine.
2232+
// Start the stall handler goroutine.
22352233
var wg sync.WaitGroup
22362234
wg.Add(1)
22372235
go func() {
2238-
m.eventHandler(ctx)
2236+
m.stallHandler(ctx)
22392237
wg.Done()
22402238
}()
22412239

0 commit comments

Comments
 (0)