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