diff --git a/internal/blocksync/pool.go b/internal/blocksync/pool.go index 1f69a03e0..b662773f1 100644 --- a/internal/blocksync/pool.go +++ b/internal/blocksync/pool.go @@ -205,16 +205,6 @@ func (pool *BlockPool) IsCaughtUp() bool { return pool.height >= (pool.maxPeerHeight - 1) } -func (pool *BlockPool) PeekBlock() (first *types.Block) { - pool.mtx.RLock() - defer pool.mtx.RUnlock() - - if r := pool.requesters[pool.height]; r != nil { - first = r.getBlock() - } - return -} - // PeekTwoBlocks returns blocks at pool.height and pool.height+1. // We need to see the second block's Commit to validate the first block. // So we peek two blocks at a time. diff --git a/internal/blocksync/pool_test.go b/internal/blocksync/pool_test.go index ae29b205e..1cb8cca40 100644 --- a/internal/blocksync/pool_test.go +++ b/internal/blocksync/pool_test.go @@ -110,8 +110,8 @@ func TestBlockPoolBasic(t *testing.T) { if !pool.IsRunning() { return } - first := pool.PeekBlock() - if first != nil { + first, second := pool.PeekTwoBlocks() + if first != nil && second != nil { pool.PopRequest() } else { time.Sleep(1 * time.Second) @@ -164,8 +164,8 @@ func TestBlockPoolTimeout(t *testing.T) { if !pool.IsRunning() { return } - first := pool.PeekBlock() - if first != nil { + first, second := pool.PeekTwoBlocks() + if first != nil && second != nil { pool.PopRequest() } else { time.Sleep(1 * time.Second)