From f2996895738b2f19d9d192133bba9e91acd4ea01 Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Sun, 4 Mar 2018 13:42:26 +0400 Subject: [PATCH] return back defaultChannelCapacity --- blockchain/pool_test.go | 8 ++++---- blockchain/reactor.go | 5 +++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/blockchain/pool_test.go b/blockchain/pool_test.go index 790216ac0..82120eaef 100644 --- a/blockchain/pool_test.go +++ b/blockchain/pool_test.go @@ -34,8 +34,8 @@ func makePeers(numPeers int, minHeight, maxHeight int64) map[p2p.ID]testPeer { func TestBasic(t *testing.T) { start := int64(42) peers := makePeers(10, start+1, 1000) - errorsCh := make(chan peerError) - requestsCh := make(chan BlockRequest) + errorsCh := make(chan peerError, 1000) + requestsCh := make(chan BlockRequest, 1000) pool := NewBlockPool(start, requestsCh, errorsCh) pool.SetLogger(log.TestingLogger()) @@ -91,8 +91,8 @@ func TestBasic(t *testing.T) { func TestTimeout(t *testing.T) { start := int64(42) peers := makePeers(10, start+1, 1000) - errorsCh := make(chan peerError) - requestsCh := make(chan BlockRequest) + errorsCh := make(chan peerError, 1000) + requestsCh := make(chan BlockRequest, 1000) pool := NewBlockPool(start, requestsCh, errorsCh) pool.SetLogger(log.TestingLogger()) err := pool.Start() diff --git a/blockchain/reactor.go b/blockchain/reactor.go index cae55e807..7462580b6 100644 --- a/blockchain/reactor.go +++ b/blockchain/reactor.go @@ -76,8 +76,9 @@ func NewBlockchainReactor(state sm.State, blockExec *sm.BlockExecutor, store *Bl store.Height())) } - requestsCh := make(chan BlockRequest) - errorsCh := make(chan peerError) + const cap = 1000 // must be bigger than peers count + requestsCh := make(chan BlockRequest, cap) + errorsCh := make(chan peerError, cap) // so we don't block in #Receive#pool.AddBlock pool := NewBlockPool( store.Height()+1, requestsCh,