Skip to content

Commit 4576ba2

Browse files
author
Manoranjith
committed
client: Refactor proposal id generation
- Use the Encode method for encoding the proposal, before hashing it. Signed-off-by: Manoranjith <ponraj.manoranjitha@in.bosch.com>
1 parent f3c6404 commit 4576ba2

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

client/proposalmsgs.go

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -278,13 +278,9 @@ func (LedgerChannelProposal) Type() wire.Type {
278278
// ProposalID returns the identifier of this channel proposal request.
279279
func (p LedgerChannelProposal) ProposalID() (propID ProposalID) {
280280
hasher := newHasher()
281-
if err := perunio.Encode(hasher,
282-
p.Base(),
283-
p.Participant,
284-
wire.Addresses(p.Peers)); err != nil {
281+
if err := perunio.Encode(hasher, p); err != nil {
285282
log.Panicf("proposal ID nonce encoding: %v", err)
286283
}
287-
288284
copy(propID[:], hasher.Sum(nil))
289285
return
290286
}
@@ -354,12 +350,9 @@ func NewSubChannelProposal(
354350
// ProposalID returns the identifier of this channel proposal request.
355351
func (p SubChannelProposal) ProposalID() (propID ProposalID) {
356352
hasher := newHasher()
357-
if err := perunio.Encode(hasher,
358-
p.Base(),
359-
p.Parent); err != nil {
353+
if err := perunio.Encode(hasher, p); err != nil {
360354
log.Panicf("proposal ID nonce encoding: %v", err)
361355
}
362-
363356
copy(propID[:], hasher.Sum(nil))
364357
return
365358
}

0 commit comments

Comments
 (0)