From f374fa2c1e0f4821f57206ad3f220a6fa5b16c39 Mon Sep 17 00:00:00 2001 From: Chao Ma Date: Sat, 21 Sep 2019 23:46:51 -0700 Subject: [PATCH] fix logic issue in GetPublicKeys function --- internal/chain/engine.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/internal/chain/engine.go b/internal/chain/engine.go index 925903f20..ea9afed3b 100644 --- a/internal/chain/engine.go +++ b/internal/chain/engine.go @@ -214,13 +214,15 @@ func (e *engineImpl) VerifyHeaderWithSignature(chain engine.ChainReader, header // GetPublicKeys finds the public keys of the committee that signed the block header func GetPublicKeys(chain engine.ChainReader, header *block.Header, reCalculate bool) ([]*bls.PublicKey, error) { var shardState shard.State + var err error if reCalculate { shardState = core.CalculateShardState(header.Epoch()) - } - shardState, err := chain.ReadShardState(header.Epoch()) - if err != nil { - return nil, ctxerror.New("failed to read shard state of epoch", - "epoch", header.Epoch().Uint64()) + } else { + shardState, err = chain.ReadShardState(header.Epoch()) + if err != nil { + return nil, ctxerror.New("failed to read shard state of epoch", + "epoch", header.Epoch().Uint64()) + } } committee := shardState.FindCommitteeByID(header.ShardID())