diff --git a/eth/backend.go b/eth/backend.go index 98eee91e1f..ea2629e690 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -148,7 +148,7 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) { eventMux: ctx.EventMux, accountManager: ctx.AccountManager, engine: CreateConsensusEngine(ctx, chainConfig, &config.Ethash, config.Miner.Notify, config.Miner.Noverify, chainDb), - closeBloomHandler: make(chan struct{}), + closeBloomHandler: make(chan struct{}, 1), networkID: config.NetworkId, gasPrice: config.Miner.GasPrice, etherbase: config.Miner.Etherbase, diff --git a/eth/downloader/downloader.go b/eth/downloader/downloader.go index f8982f696f..15f21b3850 100644 --- a/eth/downloader/downloader.go +++ b/eth/downloader/downloader.go @@ -232,7 +232,7 @@ func New(checkpoint uint64, stateDb ethdb.Database, stateBloom *trie.SyncBloom, bodyWakeCh: make(chan bool, 1), receiptWakeCh: make(chan bool, 1), headerProcCh: make(chan []*types.Header, 1), - quitCh: make(chan struct{}), + quitCh: make(chan struct{}, 1), stateCh: make(chan dataPack), stateSyncStart: make(chan *stateSync), syncStatsState: stateSyncStats{ @@ -394,7 +394,7 @@ func (d *Downloader) synchronise(id string, hash common.Hash, td *big.Int, mode } // Create cancel channel for aborting mid-flight and mark the master peer d.cancelLock.Lock() - d.cancelCh = make(chan struct{}) + d.cancelCh = make(chan struct{}, 1) d.cancelPeer = id d.cancelLock.Unlock() diff --git a/eth/downloader/statesync.go b/eth/downloader/statesync.go index f875b3a84c..465ee1cc2f 100644 --- a/eth/downloader/statesync.go +++ b/eth/downloader/statesync.go @@ -244,8 +244,8 @@ func newStateSync(d *Downloader, root common.Hash) *stateSync { keccak: sha3.NewLegacyKeccak256(), tasks: make(map[common.Hash]*stateTask), deliver: make(chan *stateReq), - cancel: make(chan struct{}), - done: make(chan struct{}), + cancel: make(chan struct{}, 1), + done: make(chan struct{}, 1), } } diff --git a/eth/fetcher/block_fetcher.go b/eth/fetcher/block_fetcher.go index 7690a53862..b1846fb64e 100644 --- a/eth/fetcher/block_fetcher.go +++ b/eth/fetcher/block_fetcher.go @@ -176,7 +176,7 @@ func NewBlockFetcher(getBlock blockRetrievalFn, verifyHeader headerVerifierFn, b headerFilter: make(chan chan *headerFilterTask), bodyFilter: make(chan chan *bodyFilterTask), done: make(chan common.Hash), - quit: make(chan struct{}), + quit: make(chan struct{}, 1), announces: make(map[string]int), announced: make(map[common.Hash][]*blockAnnounce), fetching: make(map[common.Hash]*blockAnnounce), diff --git a/eth/fetcher/tx_fetcher.go b/eth/fetcher/tx_fetcher.go index c497cebb45..4eafe81709 100644 --- a/eth/fetcher/tx_fetcher.go +++ b/eth/fetcher/tx_fetcher.go @@ -192,7 +192,7 @@ func NewTxFetcherForTests( notify: make(chan *txAnnounce), cleanup: make(chan *txDelivery), drop: make(chan *txDrop), - quit: make(chan struct{}), + quit: make(chan struct{}, 1), waitlist: make(map[common.Hash]map[string]struct{}), waittime: make(map[common.Hash]mclock.AbsTime), waitslots: make(map[string]map[common.Hash]struct{}), diff --git a/eth/handler.go b/eth/handler.go index 9a02f1f20f..320ec847bf 100644 --- a/eth/handler.go +++ b/eth/handler.go @@ -111,7 +111,7 @@ func NewProtocolManager(config *params.ChainConfig, checkpoint *params.TrustedCh peers: newPeerSet(), whitelist: whitelist, txsyncCh: make(chan *txsync), - quitSync: make(chan struct{}), + quitSync: make(chan struct{}, 1), } if mode == downloader.FullSync { diff --git a/eth/peer.go b/eth/peer.go index b4ce9237ad..b35567af5e 100644 --- a/eth/peer.go +++ b/eth/peer.go @@ -122,7 +122,7 @@ func newPeer(version int, p *p2p.Peer, rw p2p.MsgReadWriter, getPooledTx func(ha txBroadcast: make(chan []common.Hash), txAnnounce: make(chan []common.Hash), getPooledTx: getPooledTx, - term: make(chan struct{}), + term: make(chan struct{}, 1), } } @@ -179,7 +179,7 @@ func (p *peer) broadcastTransactions() { // If there's anything available to transfer, fire up an async writer if len(txs) > 0 { - done = make(chan struct{}) + done = make(chan struct{}, 1) go func() { if err := p.sendTransactions(txs); err != nil { fail <- err @@ -241,7 +241,7 @@ func (p *peer) announceTransactions() { // If there's anything available to transfer, fire up an async writer if len(pending) > 0 { - done = make(chan struct{}) + done = make(chan struct{}, 1) go func() { if err := p.sendPooledTransactionHashes(pending); err != nil { fail <- err