boltlabs-inc / zeekoe

Zero-knowledge layer-2 payment channels
MIT License
24 stars 1 forks source link

Add StartedFailed and LockedFailed states to capture errors. #342

Closed yaymukund closed 2 years ago

yaymukund commented 2 years ago

@marsella Could use your help fleshing out this PR. How should channels in PendingPayment be treated differently in the poll watcher?

marsella commented 2 years ago

We need to update the expiry case in the poll watcher. It currently checks that the channel has not entered a close state i.e. that the customer has not already responded to the expiry: https://github.com/boltlabs-inc/zeekoe/blob/main/src/bin/customer/watch.rs#L152-L155

The condition should be updated to not react to expiry if i. you have already reacted to it (PendingClose or PendingExpiry) ii. you have a payment in progress (PendingPayment or Started or Locked)

I think you can just add those three states to the condition and update the docs. Looking at it now, it's a bit hard to read, I did a

! (state1 || state2 )

but when you add a bunch more, it might be more legible to do

!state1 && !state2 && !state3 ...

The "outer" set of parens is very load-bearing right now.