mirror of
https://github.com/logos-storage/nim-nitro.git
synced 2026-01-07 08:03:14 +00:00
Replace SignedState.participants() with SignedState.hasParticipant()
This commit is contained in:
parent
e798964ba5
commit
92bad679b5
@ -8,12 +8,12 @@ type
|
|||||||
state*: State
|
state*: State
|
||||||
signatures*: seq[(EthAddress, Signature)]
|
signatures*: seq[(EthAddress, Signature)]
|
||||||
|
|
||||||
func participants*(signed: SignedState): seq[EthAddress] =
|
func hasParticipant*(signed: SignedState, participant: EthAddress): bool =
|
||||||
signed.state.channel.participants
|
signed.state.channel.participants.contains(participant)
|
||||||
|
|
||||||
func verifySignatures*(signed: SignedState): bool =
|
func verifySignatures*(signed: SignedState): bool =
|
||||||
for (participant, signature) in signed.signatures:
|
for (participant, signature) in signed.signatures:
|
||||||
if not signed.participants.contains(participant):
|
if not signed.hasParticipant(participant):
|
||||||
return false
|
return false
|
||||||
if not signature.verify(signed.state, participant):
|
if not signature.verify(signed.state, participant):
|
||||||
return false
|
return false
|
||||||
|
|||||||
@ -46,11 +46,11 @@ func openLedgerChannel*(wallet: var Wallet,
|
|||||||
let state = startLedger(wallet.address, hub, chainId, nonce, asset, amount)
|
let state = startLedger(wallet.address, hub, chainId, nonce, asset, amount)
|
||||||
wallet.createChannel(state)
|
wallet.createChannel(state)
|
||||||
|
|
||||||
func acceptChannel*(wallet: var Wallet, state: SignedState): ?!ChannelId =
|
func acceptChannel*(wallet: var Wallet, signed: SignedState): ?!ChannelId =
|
||||||
if not state.participants.contains(wallet.address):
|
if not signed.hasParticipant(wallet.address):
|
||||||
return ChannelId.failure "wallet owner is not a participant"
|
return ChannelId.failure "wallet owner is not a participant"
|
||||||
|
|
||||||
if not verifySignatures(state):
|
if not verifySignatures(signed):
|
||||||
return ChannelId.failure "incorrect signatures"
|
return ChannelId.failure "incorrect signatures"
|
||||||
|
|
||||||
wallet.createChannel(state).success
|
wallet.createChannel(signed).success
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user