Skip to content

Commit 7fadaf3

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 fa8b9e4 commit 7fadaf3

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
@@ -1878,13 +1878,11 @@ func limitAdd(m map[chainhash.Hash]struct{}, hash chainhash.Hash, limit int) {
18781878
m[hash] = struct{}{}
18791879
}
18801880

1881-
// eventHandler is the main handler for the sync manager. It must be run as a
1882-
// goroutine. It processes block and inv messages in a separate goroutine from
1883-
// the peer handlers so the block (MsgBlock) messages are handled by a single
1884-
// thread without needing to lock memory data structures. This is important
1885-
// because the sync manager controls which blocks are needed and how the
1886-
// fetching should proceed.
1887-
func (m *SyncManager) eventHandler(ctx context.Context) {
1881+
// stallHandler monitors the header sync process to detect stalls and disconnect
1882+
// the sync peer which ensures clean recovery from stalls.
1883+
//
1884+
// It must be run as a goroutine.
1885+
func (m *SyncManager) stallHandler(ctx context.Context) {
18881886
out:
18891887
for {
18901888
select {
@@ -1904,7 +1902,7 @@ out:
19041902
}
19051903
}
19061904

1907-
log.Trace("Sync manager event handler done")
1905+
log.Trace("Sync manager stall handler done")
19081906
}
19091907

19101908
// SyncPeerID returns the ID of the current sync peer, or 0 if there is none.
@@ -2119,11 +2117,11 @@ func (m *SyncManager) IsCurrent() bool {
21192117
func (m *SyncManager) Run(ctx context.Context) {
21202118
log.Trace("Starting sync manager")
21212119

2122-
// Start the event handler goroutine.
2120+
// Start the stall handler goroutine.
21232121
var wg sync.WaitGroup
21242122
wg.Add(1)
21252123
go func() {
2126-
m.eventHandler(ctx)
2124+
m.stallHandler(ctx)
21272125
wg.Done()
21282126
}()
21292127

0 commit comments

Comments
 (0)