types: Remove NewCommit constructor

Signed-off-by: Thane Thomson <connect@thanethomson.com>
This commit is contained in:
Thane Thomson
2022-05-04 17:33:31 -04:00
parent b5a94bba16
commit 59434d8513
7 changed files with 59 additions and 37 deletions
+6 -11
View File
@@ -896,16 +896,6 @@ type Commit struct {
hash tmbytes.HexBytes
}
// NewCommit returns a new Commit.
func NewCommit(height int64, round int32, blockID BlockID, commitSigs []CommitSig) *Commit {
return &Commit{
Height: height,
Round: round,
BlockID: blockID,
Signatures: commitSigs,
}
}
// GetVote converts the CommitSig for the given valIdx to a Vote. Commits do
// not contain vote extensions, so the vote extension and vote extension
// signature will not be present in the returned vote.
@@ -1122,7 +1112,12 @@ func (extCommit *ExtendedCommit) StripExtensions() *Commit {
Signature: extCommitSig.Signature,
}
}
return NewCommit(extCommit.Height, extCommit.Round, extCommit.BlockID, commitSigs)
return &Commit{
Height: extCommit.Height,
Round: extCommit.Round,
BlockID: extCommit.BlockID,
Signatures: commitSigs,
}
}
// GetExtendedVote converts the ExtendedCommitSig for the given valIdx to a
+4 -1
View File
@@ -104,7 +104,10 @@ func TestBlockValidateBasic(t *testing.T) {
blk.LastCommit = nil
}, true},
{"Invalid LastCommit", func(blk *Block) {
blk.LastCommit = NewCommit(-1, 0, *voteSet.maj23, nil)
blk.LastCommit = &Commit{
Height: -1,
BlockID: *voteSet.maj23,
}
}, true},
{"Invalid Evidence", func(blk *Block) {
emptyEv := &DuplicateVoteEvidence{}
+6 -1
View File
@@ -99,7 +99,12 @@ func TestValidatorSet_VerifyCommit_All(t *testing.T) {
vi++
}
commit := NewCommit(tc.height, round, tc.blockID, sigs)
commit := &Commit{
Height: tc.height,
Round: round,
BlockID: tc.blockID,
Signatures: sigs,
}
err := valSet.VerifyCommit(chainID, blockID, height, commit)
if tc.expErr {