Skip to content

Commit e6a93ec

Browse files
authored
Merge pull request #221 from blinklabs-io/fix/chainsync-sync-panic
fix: break out of sync loop on shutdown
2 parents a5e649b + 0bf8687 commit e6a93ec

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)