From 056aa9857067013136abacac47db50a2017dda4c Mon Sep 17 00:00:00 2001 From: Thane Thomson Date: Tue, 3 May 2022 10:51:20 -0400 Subject: [PATCH] Add helper methods to ExtendedCommitSig and ExtendedCommit Signed-off-by: Thane Thomson --- types/block.go | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/types/block.go b/types/block.go index d5da3d648..ef897b15f 100644 --- a/types/block.go +++ b/types/block.go @@ -779,14 +779,14 @@ func (ecs ExtendedCommitSig) Absent() bool { // 4. timestamp // 5. first 6 bytes of vote extension // 6. first 6 bytes of vote extension signature -func (cs ExtendedCommitSig) String() string { +func (ecs ExtendedCommitSig) String() string { return fmt.Sprintf("ExtendedCommitSig{%X by %X on %v @ %s with %X %X}", - tmbytes.Fingerprint(cs.Signature), - tmbytes.Fingerprint(cs.ValidatorAddress), - cs.BlockIDFlag, - CanonicalTime(cs.Timestamp), - tmbytes.Fingerprint(cs.VoteExtension), - tmbytes.Fingerprint(cs.ExtensionSignature), + tmbytes.Fingerprint(ecs.Signature), + tmbytes.Fingerprint(ecs.ValidatorAddress), + ecs.BlockIDFlag, + CanonicalTime(ecs.Timestamp), + tmbytes.Fingerprint(ecs.VoteExtension), + tmbytes.Fingerprint(ecs.ExtensionSignature), ) } @@ -1170,6 +1170,12 @@ func NewExtendedCommit(height int64, round int32, blockID BlockID, extCommitSigs } } +// Copy creates a copy of this extended commit. +func (extCommit *ExtendedCommit) Copy() *ExtendedCommit { + ec := *extCommit + return &ec +} + // ToVoteSet constructs a VoteSet from the Commit and validator set. // Panics if signatures from the commit can't be added to the voteset. // Inverse of VoteSet.MakeCommit().