types: Convert ExtendedCommit.Copy to a deep clone

Signed-off-by: Thane Thomson <connect@thanethomson.com>
This commit is contained in:
Thane Thomson
2022-05-04 17:38:34 -04:00
parent 386cdeff98
commit 0a31afe4c6
2 changed files with 6 additions and 3 deletions

View File

@@ -153,7 +153,7 @@ func (rts *reactorTestSuite) addNode(
seenExtCommit := &types.ExtendedCommit{}
for blockHeight := int64(1); blockHeight <= maxBlockHeight; blockHeight++ {
lastExtCommit = seenExtCommit.Copy()
lastExtCommit = seenExtCommit.Clone()
thisBlock := sf.MakeBlock(state, blockHeight, lastExtCommit.StripExtensions())
thisParts, err := thisBlock.MakePartSet(types.BlockPartSizeBytes)

View File

@@ -1073,9 +1073,12 @@ type ExtendedCommit struct {
bitArray *bits.BitArray
}
// Copy creates a copy of this extended commit.
func (ec *ExtendedCommit) Copy() *ExtendedCommit {
// Clone creates a deep copy of this extended commit.
func (ec *ExtendedCommit) Clone() *ExtendedCommit {
sigs := make([]ExtendedCommitSig, len(ec.ExtendedSignatures))
copy(sigs, ec.ExtendedSignatures)
ecc := *ec
ecc.ExtendedSignatures = sigs
return &ecc
}