Add helper methods to ExtendedCommitSig and ExtendedCommit

Signed-off-by: Thane Thomson <connect@thanethomson.com>
This commit is contained in:
Thane Thomson
2022-05-03 10:51:20 -04:00
parent 5c81f7a568
commit 056aa98570
+13 -7
View File
@@ -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().