From 221326aafc2688e562e9ae4fb4d1fca0f810aa0d Mon Sep 17 00:00:00 2001 From: Jianrong Date: Sun, 20 Feb 2022 22:10:23 +1100 Subject: [PATCH] remove isemptyhash --- consensus/XDPoS/engines/engine_v2/engine.go | 4 ++-- consensus/XDPoS/engines/engine_v2/utils.go | 9 --------- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/consensus/XDPoS/engines/engine_v2/engine.go b/consensus/XDPoS/engines/engine_v2/engine.go index 826b34041e..40c0add701 100644 --- a/consensus/XDPoS/engines/engine_v2/engine.go +++ b/consensus/XDPoS/engines/engine_v2/engine.go @@ -124,7 +124,7 @@ func (x *XDPoS_v2) SignHash(header *types.Header) (hash common.Hash) { func (x *XDPoS_v2) Initial(chain consensus.ChainReader, header *types.Header, masternodes []common.Address) error { log.Info("[Initial] initial v2 related parameters") - if !isEmptyHash(x.highestQuorumCert.ProposedBlockInfo.Hash) { // already initialized + if x.highestQuorumCert.ProposedBlockInfo.Hash != (common.Hash{}) { // already initialized log.Error("[Initial] Already initialized", "blockNum", header.Number, "Hash", header.Hash()) return nil } @@ -573,7 +573,7 @@ func (x *XDPoS_v2) verifyHeader(chain consensus.ChainReader, header *types.Heade return utils.ErrInvalidQC } - if isEmptyHash(quorumCert.ProposedBlockInfo.Hash) { + if quorumCert.ProposedBlockInfo.Hash == (common.Hash{}) { return utils.ErrEmptyBlockInfoHash } diff --git a/consensus/XDPoS/engines/engine_v2/utils.go b/consensus/XDPoS/engines/engine_v2/utils.go index 336b9f9494..be99cad26a 100644 --- a/consensus/XDPoS/engines/engine_v2/utils.go +++ b/consensus/XDPoS/engines/engine_v2/utils.go @@ -68,12 +68,3 @@ func decodeMasternodesFromHeaderExtra(checkpointHeader *types.Header) []common.A } return masternodes } - -func isEmptyHash(hash common.Hash) bool { - for _, b := range hash { - if b != 0 { - return false - } - } - return true -}