Skip to content

Commit

Permalink
channel: Use CloneAddresses in Params.Clone
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastian Stammler <[email protected]>
  • Loading branch information
sebastianst committed Mar 16, 2022
1 parent 9659076 commit f4cd1c0
Showing 1 changed file with 1 addition and 15 deletions.
16 changes: 1 addition & 15 deletions channel/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,24 +146,10 @@ func NewParamsUnsafe(challengeDuration uint64, parts []wallet.Address, app App,

// Clone returns a deep copy of Params.
func (p *Params) Clone() *Params {
clonedParts := make([]wallet.Address, len(p.Parts))
for i, part := range p.Parts {
marshalledAddr, err := part.MarshalBinary()
if err != nil {
log.WithError(err).Panic("Could not encode part")
}

addr := wallet.NewAddress()
if err := addr.UnmarshalBinary(marshalledAddr); err != nil {
log.WithError(err).Panic("Could not clone params' addresses")
}
clonedParts[i] = addr
}

return &Params{
id: p.ID(),
ChallengeDuration: p.ChallengeDuration,
Parts: clonedParts,
Parts: wallet.CloneAddresses(p.Parts),
App: p.App,
Nonce: new(big.Int).Set(p.Nonce),
LedgerChannel: p.LedgerChannel,
Expand Down

0 comments on commit f4cd1c0

Please sign in to comment.