aboutsummaryrefslogtreecommitdiffstats
path: root/core/block_cache.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-04-05 02:34:10 +0800
committerobscuren <geffobscura@gmail.com>2015-04-05 02:34:10 +0800
commitc39484bc4b099881c3aa164d33b5ba95c55f36fa (patch)
tree04f58fa6347f078305b061f08957af9b9da04737 /core/block_cache.go
parenteff6a43419c6f0653880e05271811b93f4b6e56a (diff)
downloadgo-tangerine-c39484bc4b099881c3aa164d33b5ba95c55f36fa.tar.gz
go-tangerine-c39484bc4b099881c3aa164d33b5ba95c55f36fa.tar.zst
go-tangerine-c39484bc4b099881c3aa164d33b5ba95c55f36fa.zip
Added thread safe each
Diffstat (limited to 'core/block_cache.go')
-rw-r--r--core/block_cache.go11
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++
+ }
+}