mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-21 14:14:30 +00:00
log improvement and some refactor (#110)
This commit is contained in:
parent
cfb5c6ce39
commit
e55fca6703
4 changed files with 25 additions and 25 deletions
|
|
@ -477,7 +477,7 @@ func (x *XDPoS_v2) UpdateMasternodes(chain consensus.ChainReader, header *types.
|
|||
func (x *XDPoS_v2) VerifyHeader(chain consensus.ChainReader, header *types.Header, fullVerify bool) error {
|
||||
err := x.verifyHeader(chain, header, nil, fullVerify)
|
||||
if err != nil {
|
||||
log.Warn("[VerifyHeader] Fail to verify header", "fullVerify", fullVerify, "blockNum", header.Number, "blockHash", header.Hash(), "error", err)
|
||||
log.Debug("[VerifyHeader] Fail to verify header", "fullVerify", fullVerify, "blockNum", header.Number, "blockHash", header.Hash(), "error", err)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
|
@ -558,7 +558,7 @@ func (x *XDPoS_v2) VerifyVoteMessage(chain consensus.ChainReader, vote *types.Vo
|
|||
4. Broadcast(Not part of consensus)
|
||||
*/
|
||||
if vote.ProposedBlockInfo.Round < x.currentRound {
|
||||
log.Warn("[VerifyVoteMessage] Disqualified vote message as the proposed round does not match currentRound", "vote.ProposedBlockInfo.Round", vote.ProposedBlockInfo.Round, "currentRound", x.currentRound)
|
||||
log.Debug("[VerifyVoteMessage] Disqualified vote message as the proposed round does not match currentRound", "vote.ProposedBlockInfo.Round", vote.ProposedBlockInfo.Round, "currentRound", x.currentRound)
|
||||
return false, nil
|
||||
}
|
||||
|
||||
|
|
@ -869,7 +869,7 @@ func (x *XDPoS_v2) commitBlocks(blockChainReader consensus.ChainReader, proposed
|
|||
return false, err
|
||||
}
|
||||
if *proposedBlockRound-1 != round {
|
||||
log.Debug("[commitBlocks] Rounds not continuous(parent) found when committing block", "proposedBlockRound", proposedBlockRound, "decodedExtraField.Round", round, "proposedBlockHeaderHash", proposedBlockHeader.Hash())
|
||||
log.Info("[commitBlocks] Rounds not continuous(parent) found when committing block", "proposedBlockRound", proposedBlockRound, "decodedExtraField.Round", round, "proposedBlockHeaderHash", proposedBlockHeader.Hash())
|
||||
return false, nil
|
||||
}
|
||||
|
||||
|
|
@ -881,25 +881,25 @@ func (x *XDPoS_v2) commitBlocks(blockChainReader consensus.ChainReader, proposed
|
|||
return false, err
|
||||
}
|
||||
if *proposedBlockRound-2 != round {
|
||||
log.Debug("[commitBlocks] Rounds not continuous(grand parent) found when committing block", "proposedBlockRound", proposedBlockRound, "decodedExtraField.Round", round, "proposedBlockHeaderHash", proposedBlockHeader.Hash())
|
||||
log.Info("[commitBlocks] Rounds not continuous(grand parent) found when committing block", "proposedBlockRound", proposedBlockRound, "decodedExtraField.Round", round, "proposedBlockHeaderHash", proposedBlockHeader.Hash())
|
||||
return false, nil
|
||||
}
|
||||
// Commit the grandParent block
|
||||
if x.highestCommitBlock == nil || (x.highestCommitBlock.Round < round && x.highestCommitBlock.Number.Cmp(grandParentBlock.Number) == -1) {
|
||||
x.highestCommitBlock = &types.BlockInfo{
|
||||
Number: grandParentBlock.Number,
|
||||
Hash: grandParentBlock.Hash(),
|
||||
Round: round,
|
||||
}
|
||||
log.Debug("Successfully committed block", "Committed block Hash", x.highestCommitBlock.Hash, "Committed round", x.highestCommitBlock.Round)
|
||||
// Perform forensics related operation
|
||||
var headerQcToBeCommitted []types.Header
|
||||
headerQcToBeCommitted = append(headerQcToBeCommitted, *parentBlock, *proposedBlockHeader)
|
||||
go x.ForensicsProcessor.ForensicsMonitoring(blockChainReader, x, headerQcToBeCommitted, *incomingQc)
|
||||
return true, nil
|
||||
|
||||
if x.highestCommitBlock != nil && (x.highestCommitBlock.Round >= round || x.highestCommitBlock.Number.Cmp(grandParentBlock.Number) == 1) {
|
||||
return false, nil
|
||||
}
|
||||
// Everything else, fail to commit
|
||||
return false, nil
|
||||
|
||||
// Process Commit
|
||||
x.highestCommitBlock = &types.BlockInfo{
|
||||
Number: grandParentBlock.Number,
|
||||
Hash: grandParentBlock.Hash(),
|
||||
Round: round,
|
||||
}
|
||||
log.Info("Successfully committed block", "num", x.highestCommitBlock.Number, "round", x.highestCommitBlock.Round, "hash", x.highestCommitBlock.Hash)
|
||||
// Perform forensics related operation
|
||||
headerQcToBeCommitted := []types.Header{*parentBlock, *proposedBlockHeader}
|
||||
go x.ForensicsProcessor.ForensicsMonitoring(blockChainReader, x, headerQcToBeCommitted, *incomingQc)
|
||||
return true, nil
|
||||
}
|
||||
|
||||
// Get master nodes over extra data of epoch switch block.
|
||||
|
|
|
|||
|
|
@ -404,12 +404,11 @@ func CalculateRewardForSigner(chainReward *big.Int, signers map[common.Address]*
|
|||
resultSigners[signer] = calcReward
|
||||
}
|
||||
}
|
||||
jsonSigners, err := json.Marshal(signers)
|
||||
if err != nil {
|
||||
log.Error("Fail to parse json signers", "error", err)
|
||||
return nil, err
|
||||
|
||||
log.Info("Signers data", "totalSigner", totalSigner, "totalReward", chainReward)
|
||||
for addr, signer := range signers {
|
||||
log.Info("Signer reward", "signer", addr, "sign", signer.Sign, "reward", signer.Reward)
|
||||
}
|
||||
log.Info("Signers data", "signers", string(jsonSigners), "totalSigner", totalSigner, "totalReward", chainReward)
|
||||
|
||||
return resultSigners, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -189,6 +189,7 @@ func (api *PrivateMinerAPI) SetGasPrice(gasPrice hexutil.Big) bool {
|
|||
|
||||
// SetEtherbase sets the etherbase of the miner
|
||||
func (api *PrivateMinerAPI) SetEtherbase(etherbase common.Address) bool {
|
||||
log.Info("[PrivateMinerAPI] SetEtherbase", "addr", etherbase)
|
||||
api.e.SetEtherbase(etherbase)
|
||||
return true
|
||||
}
|
||||
|
|
|
|||
|
|
@ -717,7 +717,7 @@ func (f *Fetcher) insert(peer string, block *types.Block) {
|
|||
}
|
||||
// Run the actual import and log any issues
|
||||
if err := f.insertBlock(block); err != nil {
|
||||
log.Debug("Propagated block import failed", "peer", peer, "number", block.Number(), "hash", hash, "err", err)
|
||||
log.Warn("Propagated block import failed", "peer", peer, "number", block.Number(), "hash", hash, "err", err)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue