diff --git a/consensus/XDPoS/engines/engine_v2/mining.go b/consensus/XDPoS/engines/engine_v2/mining.go index 22a57653b4..f58eda075a 100644 --- a/consensus/XDPoS/engines/engine_v2/mining.go +++ b/consensus/XDPoS/engines/engine_v2/mining.go @@ -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 } diff --git a/consensus/XDPoS/engines/engine_v2/utils.go b/consensus/XDPoS/engines/engine_v2/utils.go index 74a557b670..1b4119d29d 100644 --- a/consensus/XDPoS/engines/engine_v2/utils.go +++ b/consensus/XDPoS/engines/engine_v2/utils.go @@ -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) diff --git a/consensus/XDPoS/utils/pool.go b/consensus/XDPoS/utils/pool.go index 57f6b93a0f..1d65fae6f2 100644 --- a/consensus/XDPoS/utils/pool.go +++ b/consensus/XDPoS/utils/pool.go @@ -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) {