improve test util
This commit is contained in:
parent
ed8c39dd41
commit
9ab1589d2d
@ -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 {
|
||||||
|
Loading…
Reference in New Issue
Block a user