improve test util

This commit is contained in:
Roy Crihfield 2023-08-11 15:57:58 +08:00
parent ed8c39dd41
commit 9ab1589d2d

View File

@ -6,7 +6,7 @@ import (
type atomicBlockSet struct { type atomicBlockSet struct {
blocks map[uint64]struct{} blocks map[uint64]struct{}
sync.Mutex sync.RWMutex
} }
func newBlockSet() *atomicBlockSet { func newBlockSet() *atomicBlockSet {
@ -14,14 +14,10 @@ func newBlockSet() *atomicBlockSet {
} }
func (set *atomicBlockSet) contains(block uint64) bool { func (set *atomicBlockSet) contains(block uint64) bool {
set.Lock() set.RLock()
defer set.Unlock() defer set.RUnlock()
for done := range set.blocks { _, has := set.blocks[block]
if done == block { return has
return true
}
}
return false
} }
func (set *atomicBlockSet) containsAll(blocks []uint64) bool { func (set *atomicBlockSet) containsAll(blocks []uint64) bool {