get10101 / 10101-PoC

The world needs more Lightning!
MIT License
17 stars 3 forks source link

feat: Wait for channel to become available #496

Closed holzeis closed 1 year ago

holzeis commented 1 year ago

Before that PR we where only depending on a timeout and a lightning balance. However, this led to several error messages as a lightning balance does not mean the channel is usable.

The PR introduces a sync of the channel state every 5 seconds representing the following 3 states:

  1. Unavailable: No channel exists
  2. Establishing: Channel exists but is not usable yet
  3. Available: Channel exists and is usable

ebe4fb219a61b1802e673723916a77b8bad79ad4 fixes a regression after merging https://github.com/itchysats/10101/pull/483: we can not assume there is always a channel available. The taker was trying to reconnect constantly if no channel was available or if it was in creation. It's hard to distinguish between a good and a bad usable channel (as it might be in creation) - I am using the short_channel_id now to distinguish if the channel is actually in a bad state or everything is fine.

bonomat commented 1 year ago

I'm taking over this last bit :)

bonomat commented 1 year ago

@klochowicz / @luckysori / @da-kami : please have another look at my fixup: 477e8e2 (#496). I don't think the logic is needed:

is_first_channel_usable uses is_usable: channel.is_live(), which checks if channel_state=ChannelState::PeerDisconnected. So no need to have another check

bonomat commented 1 year ago

Rebased and going ahead to merge this.

bors r+

bors[bot] commented 1 year ago

Build succeeded: