mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-15 09:20:44 +00:00
XDPoS/utils: get pool size by key, close XFN-21 (#1666)
This commit is contained in:
parent
4faefad7a5
commit
bd3d30919d
2 changed files with 4 additions and 4 deletions
|
|
@ -36,12 +36,12 @@ func (x *XDPoS_v2) GetCurrentRoundFaker() types.Round {
|
||||||
|
|
||||||
// Utils for test to get current Pool size
|
// Utils for test to get current Pool size
|
||||||
func (x *XDPoS_v2) GetVotePoolSizeFaker(vote *types.Vote) int {
|
func (x *XDPoS_v2) GetVotePoolSizeFaker(vote *types.Vote) int {
|
||||||
return x.votePool.Size(vote)
|
return x.votePool.Size(vote.PoolKey())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Utils for test to get Timeout Pool Size
|
// Utils for test to get Timeout Pool Size
|
||||||
func (x *XDPoS_v2) GetTimeoutPoolSizeFaker(timeout *types.Timeout) int {
|
func (x *XDPoS_v2) GetTimeoutPoolSizeFaker(timeout *types.Timeout) int {
|
||||||
return x.timeoutPool.Size(timeout)
|
return x.timeoutPool.Size(timeout.PoolKey())
|
||||||
}
|
}
|
||||||
|
|
||||||
// WARN: This function is designed for testing purpose only!
|
// WARN: This function is designed for testing purpose only!
|
||||||
|
|
|
||||||
|
|
@ -59,10 +59,10 @@ func (p *Pool) Add(obj PoolObj) (int, map[common.Hash]PoolObj) {
|
||||||
return numOfItems, dataCopy
|
return numOfItems, dataCopy
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Pool) Size(obj PoolObj) int {
|
func (p *Pool) Size(poolKey string) int {
|
||||||
p.lock.RLock()
|
p.lock.RLock()
|
||||||
defer p.lock.RUnlock()
|
defer p.lock.RUnlock()
|
||||||
poolKey := obj.PoolKey()
|
|
||||||
objListKeyed, ok := p.objList[poolKey]
|
objListKeyed, ok := p.objList[poolKey]
|
||||||
if !ok {
|
if !ok {
|
||||||
return 0
|
return 0
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue