diff options
Diffstat (limited to 'core/block_cache.go')
-rw-r--r-- | core/block_cache.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/core/block_cache.go b/core/block_cache.go index 768d3bf19..eeef5c41d 100644 --- a/core/block_cache.go +++ b/core/block_cache.go @@ -88,3 +88,14 @@ func (bc *BlockCache) Has(hash common.Hash) bool { _, ok := bc.blocks[hash] return ok } + +func (bc *BlockCache) Each(cb func(int, *types.Block)) { + bc.mu.Lock() + defer bc.mu.Unlock() + + i := 0 + for _, block := range bc.blocks { + cb(i, block) + i++ + } +} |