blocksync/pool: reverted to PeekTwoBlocks

This commit is contained in:
Jasmina Malicevic
2022-04-27 15:34:51 +02:00
parent 2a31843f8d
commit 3654fc9fae
2 changed files with 4 additions and 14 deletions

View File

@@ -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.

View File

@@ -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)