Skip to content

Commit 0bf8687

Browse files
committed
fix: break out of sync loop on shutdown
Fixes #220
1 parent a5e649b commit 0bf8687

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

protocol/chainsync/client.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,10 @@ func (c *Client) Sync(intersectPoints []common.Point) error {
146146
func (c *Client) syncLoop() {
147147
for {
148148
// Wait for a block to be received
149-
<-c.readyForNextBlockChan
149+
if _, ok := <-c.readyForNextBlockChan; !ok {
150+
// Channel is closed, which means we're shutting down
151+
return
152+
}
150153
c.busyMutex.Lock()
151154
// Request the next block
152155
// In practice we already have multiple block requests pipelined

0 commit comments

Comments
 (0)