eth: fix transaction announce/broadcast goroutine leak

This commit is contained in:
Péter Szilágyi 2020-03-13 23:47:15 +02:00
parent 92f3405dae
commit 270fbfba4b
No known key found for this signature in database
GPG Key ID: E9AE538CEDF8293D

View File

@ -155,9 +155,9 @@ func (p *peer) broadcastBlocks() {
// node internals and at the same time rate limits queued data. // node internals and at the same time rate limits queued data.
func (p *peer) broadcastTransactions() { func (p *peer) broadcastTransactions() {
var ( var (
queue []common.Hash // Queue of hashes to broadcast as full transactions queue []common.Hash // Queue of hashes to broadcast as full transactions
done chan struct{} // Non-nil if background broadcaster is running done chan struct{} // Non-nil if background broadcaster is running
fail = make(chan error) // Channel used to receive network error fail = make(chan error, 1) // Channel used to receive network error
) )
for { for {
// If there's no in-flight broadcast running, check if a new one is needed // If there's no in-flight broadcast running, check if a new one is needed
@ -217,9 +217,9 @@ func (p *peer) broadcastTransactions() {
// node internals and at the same time rate limits queued data. // node internals and at the same time rate limits queued data.
func (p *peer) announceTransactions() { func (p *peer) announceTransactions() {
var ( var (
queue []common.Hash // Queue of hashes to announce as transaction stubs queue []common.Hash // Queue of hashes to announce as transaction stubs
done chan struct{} // Non-nil if background announcer is running done chan struct{} // Non-nil if background announcer is running
fail = make(chan error) // Channel used to receive network error fail = make(chan error, 1) // Channel used to receive network error
) )
for { for {
// If there's no in-flight announce running, check if a new one is needed // If there's no in-flight announce running, check if a new one is needed