log on stripped extensions

This commit is contained in:
William Banfield
2022-05-19 12:53:17 -04:00
parent be9b4a7fc0
commit 5031c82150
4 changed files with 19 additions and 9 deletions
+6 -1
View File
@@ -1105,11 +1105,16 @@ func (ec *ExtendedCommit) EnsureExtensions() error {
// StripExtensions removes all VoteExtension data from an ExtendedCommit. This
// is useful when dealing with an ExendedCommit but vote extension data is
// expected to be absent.
func (ec *ExtendedCommit) StripExtensions() {
func (ec *ExtendedCommit) StripExtensions() bool {
stripped := false
for idx := range ec.ExtendedSignatures {
if len(ec.ExtendedSignatures[idx].Extension) > 0 || len(ec.ExtendedSignatures[idx].ExtensionSignature) > 0 {
stripped = true
}
ec.ExtendedSignatures[idx].Extension = nil
ec.ExtendedSignatures[idx].ExtensionSignature = nil
}
return stripped
}
// ToCommit converts an ExtendedCommit to a Commit by removing all vote
+5 -2
View File
@@ -112,11 +112,14 @@ func (vote *Vote) CommitSig() CommitSig {
}
}
// StripExtensions removes any extension data from the vote. Useful if the
// StripExtension removes any extension data from the vote. Useful if the
// chain has not enabled vote extensions.
func (vote *Vote) StripExtensions() {
// Returns true if extension data was present before stripping and false otherwise.
func (vote *Vote) StripExtension() bool {
stripped := len(vote.Extension) > 0 || len(vote.ExtensionSignature) > 0
vote.Extension = nil
vote.ExtensionSignature = nil
return stripped
}
// ExtendedCommitSig attempts to construct an ExtendedCommitSig from this vote.