Skip to content

Commit 786f876

Browse files
committed
fix: add logic for the buffer clean up
1 parent 22ab669 commit 786f876

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

eth/protocols/eth/peer.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,8 @@ func (p *Peer) BufferReceiptsPacket(packet *ReceiptsPacket70, backend Backend) e
413413
}
414414

415415
if len(packet.List) == 0 {
416+
delete(p.receiptBuffer, requestId)
417+
delete(p.requestedReceipts, requestId)
416418
return nil
417419
}
418420

@@ -444,13 +446,14 @@ func (p *Peer) BufferReceiptsPacket(packet *ReceiptsPacket70, backend Backend) e
444446
return nil
445447
}
446448

447-
// If the request is completed, append previously collected receipts
448-
// to the packet and remove the buffered receipts.
449+
// Request completed
449450
if buffer, ok := p.receiptBuffer[requestId]; ok {
451+
// If the request is completed, append previously collected receipts
452+
// to the packet and remove the buffered receipts.
450453
packet.List = append(buffer.list, packet.List...)
451454
delete(p.receiptBuffer, requestId)
452-
delete(p.requestedReceipts, requestId)
453455
}
456+
delete(p.requestedReceipts, requestId)
454457

455458
return nil
456459
}

0 commit comments

Comments
 (0)