Skip to content

Commit

Permalink
[blocksync] remove redundant clean-up (#4505)
Browse files Browse the repository at this point in the history
  • Loading branch information
dustinxie authored Dec 9, 2024
1 parent 1f852bc commit d5df01a
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 22 deletions.
1 change: 0 additions & 1 deletion blocksync/blocksync.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,6 @@ func (bs *blockSyncer) ProcessBlock(ctx context.Context, peer string, blk *block
}
syncedHeight++
}
bs.buf.Cleanup(syncedHeight)
log.L().Debug("flush blocks", zap.Uint64("start", tip), zap.Uint64("end", syncedHeight))
if syncedHeight > bs.lastTip {
bs.lastTip = syncedHeight
Expand Down
21 changes: 0 additions & 21 deletions blocksync/buffer.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ package blocksync

import (
"sync"

"go.uber.org/zap"

"github.com/iotexproject/iotex-core/v2/pkg/log"
)

// blockBuffer is used to keep in-coming block in order.
Expand Down Expand Up @@ -47,23 +43,6 @@ func (b *blockBuffer) Pop(height uint64) []*peerBlock {
return blks
}

func (b *blockBuffer) Cleanup(height uint64) {
b.mu.Lock()
defer b.mu.Unlock()

size := len(b.blockQueues)
if size > int(b.bufferSize)*2 {
log.L().Warn("blockBuffer is leaking memory.", zap.Int("bufferSize", size))
newQueues := map[uint64]*uniQueue{}
for h := range b.blockQueues {
if h > height {
newQueues[h] = b.blockQueues[h]
}
}
b.blockQueues = newQueues
}
}

// AddBlock tries to put given block into buffer and flush buffer into blockchain.
func (b *blockBuffer) AddBlock(tipHeight uint64, blk *peerBlock) (bool, uint64) {
b.mu.Lock()
Expand Down

0 comments on commit d5df01a

Please sign in to comment.