mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-16 18:00:46 +00:00
XDPoS/utils: must use NewPool() to create Pool, close XFN-13 (#1667)
This commit is contained in:
parent
956ebb2b02
commit
39b8184f57
1 changed files with 3 additions and 0 deletions
|
|
@ -12,6 +12,8 @@ type PoolObj interface {
|
||||||
GetSigner() common.Address
|
GetSigner() common.Address
|
||||||
DeepCopy() interface{}
|
DeepCopy() interface{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Note: must use `NewPool()` to create `Pool` since field `objList` is a map
|
||||||
type Pool struct {
|
type Pool struct {
|
||||||
objList map[string]map[common.Hash]PoolObj
|
objList map[string]map[common.Hash]PoolObj
|
||||||
lock sync.RWMutex // Protects the pool fields
|
lock sync.RWMutex // Protects the pool fields
|
||||||
|
|
@ -22,6 +24,7 @@ func NewPool() *Pool {
|
||||||
objList: make(map[string]map[common.Hash]PoolObj),
|
objList: make(map[string]map[common.Hash]PoolObj),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Pool) Get() map[string]map[common.Hash]PoolObj {
|
func (p *Pool) Get() map[string]map[common.Hash]PoolObj {
|
||||||
p.lock.RLock()
|
p.lock.RLock()
|
||||||
defer p.lock.RUnlock()
|
defer p.lock.RUnlock()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue