From 0a31afe4c6badb55c14a10e0791c7e79b0d88364 Mon Sep 17 00:00:00 2001 From: Thane Thomson Date: Wed, 4 May 2022 17:38:34 -0400 Subject: [PATCH] types: Convert ExtendedCommit.Copy to a deep clone Signed-off-by: Thane Thomson --- internal/blocksync/reactor_test.go | 2 +- types/block.go | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/internal/blocksync/reactor_test.go b/internal/blocksync/reactor_test.go index c8a8c79b8..1d4d7d4d6 100644 --- a/internal/blocksync/reactor_test.go +++ b/internal/blocksync/reactor_test.go @@ -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) diff --git a/types/block.go b/types/block.go index c81caf213..4f0e22751 100644 --- a/types/block.go +++ b/types/block.go @@ -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 }