arc cache is threadsafe
This commit is contained in:
parent
b333247fab
commit
bb974d23e6
@ -1,14 +1,11 @@
|
||||
package chain
|
||||
|
||||
import (
|
||||
"sync"
|
||||
|
||||
lru "github.com/hashicorp/golang-lru"
|
||||
"github.com/ipfs/go-cid"
|
||||
)
|
||||
|
||||
type BadBlockCache struct {
|
||||
lk sync.Mutex
|
||||
badBlocks *lru.ARCCache
|
||||
}
|
||||
|
||||
@ -24,13 +21,9 @@ func NewBadBlockCache() *BadBlockCache {
|
||||
}
|
||||
|
||||
func (bts *BadBlockCache) Add(c cid.Cid) {
|
||||
bts.lk.Lock()
|
||||
defer bts.lk.Unlock()
|
||||
bts.badBlocks.Add(c, nil)
|
||||
}
|
||||
|
||||
func (bts *BadBlockCache) Has(c cid.Cid) bool {
|
||||
bts.lk.Lock()
|
||||
defer bts.lk.Unlock()
|
||||
return bts.badBlocks.Contains(c)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user