mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-18 10:50:44 +00:00
useful logging (#1986)
This commit is contained in:
parent
872c1248f3
commit
6120def776
3 changed files with 17 additions and 4 deletions
|
|
@ -53,10 +53,10 @@ func (x *XDPoS_v2) yourturn(chain consensus.ChainReader, round types.Round, pare
|
||||||
leaderIndex := uint64(round) % x.config.Epoch % uint64(len(masterNodes))
|
leaderIndex := uint64(round) % x.config.Epoch % uint64(len(masterNodes))
|
||||||
x.whosTurn = masterNodes[leaderIndex]
|
x.whosTurn = masterNodes[leaderIndex]
|
||||||
if x.whosTurn != signer {
|
if x.whosTurn != signer {
|
||||||
log.Info("[yourturn] Not my turn", "curIndex", curIndex, "leaderIndex", leaderIndex, "Hash", parent.Hash().Hex(), "whosTurn", x.whosTurn.Hex(), "myaddr", signer.Hex())
|
log.Info("[yourturn] Not my turn", "round", round, "curIndex", curIndex, "leaderIndex", leaderIndex, "Hash", parent.Hash().Hex(), "whosTurn", x.whosTurn, "myaddr", signer)
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Info("[yourturn] Yes, it's my turn based on parent block", "ParentHash", parent.Hash().Hex(), "ParentBlockNumber", parent.Number.Uint64())
|
log.Info("[yourturn] Yes, it's my turn based on parent block", "round", round, "ParentHash", parent.Hash().Hex(), "ParentBlockNumber", parent.Number.Uint64())
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -320,10 +320,10 @@ func (x *XDPoS_v2) GetBlockByEpochNumber(chain consensus.ChainReader, targetEpoc
|
||||||
return epochSwitchInfo.EpochSwitchBlockInfo, nil
|
return epochSwitchInfo.EpochSwitchBlockInfo, nil
|
||||||
}
|
}
|
||||||
if targetEpochNum > epochNum {
|
if targetEpochNum > epochNum {
|
||||||
return nil, errors.New("input epoch number > current epoch number")
|
return nil, fmt.Errorf("input epoch number > current epoch number, targetEpochNum:%d, epochNum:%d", targetEpochNum, epochNum)
|
||||||
}
|
}
|
||||||
if targetEpochNum < x.config.V2.SwitchEpoch {
|
if targetEpochNum < x.config.V2.SwitchEpoch {
|
||||||
return nil, errors.New("input epoch number < v2 begin epoch number")
|
return nil, fmt.Errorf("input epoch number < v2 begin epoch number, targetEpochNum:%d, x.config.V2.SwitchEpoch:%d", targetEpochNum, x.config.V2.SwitchEpoch)
|
||||||
}
|
}
|
||||||
// the block's round should be in [estRound,estRound+Epoch-1]
|
// the block's round should be in [estRound,estRound+Epoch-1]
|
||||||
estRound := types.Round((targetEpochNum - x.config.V2.SwitchEpoch) * x.config.Epoch)
|
estRound := types.Round((targetEpochNum - x.config.V2.SwitchEpoch) * x.config.Epoch)
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/XinFinOrg/XDPoSChain/common"
|
"github.com/XinFinOrg/XDPoSChain/common"
|
||||||
|
"github.com/XinFinOrg/XDPoSChain/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
type PoolObj interface {
|
type PoolObj interface {
|
||||||
|
|
@ -39,6 +40,18 @@ func (p *Pool) Get() map[string]map[common.Hash]PoolObj {
|
||||||
return dataCopy
|
return dataCopy
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p *Pool) Inspect() {
|
||||||
|
p.lock.RLock()
|
||||||
|
defer p.lock.RUnlock()
|
||||||
|
|
||||||
|
for poolKey, objMap := range p.objList {
|
||||||
|
log.Info("[Inspect] Pool Key:", "poolKey", poolKey, "numObjects", len(objMap))
|
||||||
|
for objHash, obj := range objMap {
|
||||||
|
log.Info("[Inspect] Object Hash:", "objHash", objHash.Hex(), "signer", obj.GetSigner())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Add adds the object to the pool, returns the number of items
|
// Add adds the object to the pool, returns the number of items
|
||||||
// and the map of objects under the same pool key
|
// and the map of objects under the same pool key
|
||||||
func (p *Pool) Add(obj PoolObj) (int, map[common.Hash]PoolObj) {
|
func (p *Pool) Add(obj PoolObj) (int, map[common.Hash]PoolObj) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue