breez / breez-sdk-greenlight

MIT License
244 stars 43 forks source link

wrap breez services with replaceable variant #1112

Closed JssDWt closed 3 weeks ago

JssDWt commented 4 weeks ago

If an app hibernates, the breez sdk may still run. However, any connections to the outside world, like grpc connections will (may) stop functioning. This means after hibernation the sdk needs to reconnect. Hibernation is detected by awaiting a 'sleep' in a loop. If the sleep has taken a long time, that means the app has been in hibernation. Because many services have references to the node api, and other services than the greenlight client may have been affected by hibernation, the entire breezservices instance is recreated, reconnected. In order to allow this, an internal variant of breezservices was made. This internal instance can be replaced at any time.

Because the breezservices code was moved to another file, with edits, I took the liberty of putting all functions inside breezservices in alphabetical order.

Related: https://github.com/Blockstream/greenlight/issues/521

Tested with c-breez build https://github.com/breez/c-breez/actions/runs/11519175590 I see the app hibernating and succesfully reconnecting.

TODO: The SDK is in an unrecoverable state right now if the reconnect fails.

Review remarks:

JssDWt commented 3 weeks ago

Closing in favor of #1115