useful logging (#1986)

This commit is contained in:
Wanwiset Peerapatanapokin 2026-02-06 17:42:26 +07:00 committed by GitHub
parent 872c1248f3
commit 6120def776
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 17 additions and 4 deletions

View file

@ -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))
x.whosTurn = masterNodes[leaderIndex]
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
}
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
}

View file

@ -320,10 +320,10 @@ func (x *XDPoS_v2) GetBlockByEpochNumber(chain consensus.ChainReader, targetEpoc
return epochSwitchInfo.EpochSwitchBlockInfo, nil
}
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 {
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]
estRound := types.Round((targetEpochNum - x.config.V2.SwitchEpoch) * x.config.Epoch)

View file

@ -4,6 +4,7 @@ import (
"sync"
"github.com/XinFinOrg/XDPoSChain/common"
"github.com/XinFinOrg/XDPoSChain/log"
)
type PoolObj interface {
@ -39,6 +40,18 @@ func (p *Pool) Get() map[string]map[common.Hash]PoolObj {
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
// and the map of objects under the same pool key
func (p *Pool) Add(obj PoolObj) (int, map[common.Hash]PoolObj) {