Skip to content

Commit

Permalink
fix: break out of sync loop on shutdown
Browse files Browse the repository at this point in the history
Fixes #220
  • Loading branch information
agaffney committed Apr 3, 2023
1 parent a5e649b commit 0bf8687
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion protocol/chainsync/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,10 @@ func (c *Client) Sync(intersectPoints []common.Point) error {
func (c *Client) syncLoop() {
for {
// Wait for a block to be received
<-c.readyForNextBlockChan
if _, ok := <-c.readyForNextBlockChan; !ok {
// Channel is closed, which means we're shutting down
return
}
c.busyMutex.Lock()
// Request the next block
// In practice we already have multiple block requests pipelined
Expand Down

0 comments on commit 0bf8687

Please sign in to comment.