From a3b3415a3ac2b30e09a16486af8ab51d1974f101 Mon Sep 17 00:00:00 2001 From: Thane Thomson Date: Wed, 4 May 2022 14:12:15 -0400 Subject: [PATCH] types: Reformat ExtendedCommitSig.BlockID Signed-off-by: Thane Thomson --- types/block.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/types/block.go b/types/block.go index e8ff59c97..13b99c643 100644 --- a/types/block.go +++ b/types/block.go @@ -777,19 +777,18 @@ func (ecs ExtendedCommitSig) String() string { ) } +// BlockID returns the block ID associated with this extended commit signature, +// if any. If the block ID flag is neither absent, nil nor commit, this panics. +// If the block ID flag is absent or nil this returns an empty BlockID. func (ecs ExtendedCommitSig) BlockID(commitBlockID BlockID) BlockID { - var blockID BlockID switch ecs.BlockIDFlag { - case BlockIDFlagAbsent: - blockID = BlockID{} + case BlockIDFlagAbsent, BlockIDFlagNil: + return BlockID{} case BlockIDFlagCommit: - blockID = commitBlockID - case BlockIDFlagNil: - blockID = BlockID{} + return commitBlockID default: panic(fmt.Sprintf("Unknown BlockIDFlag: %v", ecs.BlockIDFlag)) } - return blockID } // ValidateBasic checks whether the structure is well-formed.