Add shutdown signal (#238)

* Add shutdown signal handling

Revert periodic sync interval change

Revert keep-alive interval change

CLI: Add disconnect command

SDK: Add scaffolding for is_started, shutdown()

Simplify instance init

* Rebase on savage-async-ws branch

* Avoid waiting when shutdown signal is received in the sync loop

* Directly use shutdown signal in background threads

* Acquire is_started lock at the very beginning of start()

* Fix cargo clippy warnings

* Update RN generator (kt): set bindingLiquidSdk to null on disconnect()

* Update RN generator (swift): set bindingLiquidSdk to nil on disconnect()

* Startup: only run foreground sync() if this could be the first run

* Start a sync() in background, before regular sync() loop

* Remove ensure_started check from start()

* Add bindings for disconnect()

* Remove foreground sync condition from startup

* Simplify background sync loop
This commit is contained in:
ok300
2024-05-30 08:04:30 +00:00
committed by GitHub
parent e986f75605
commit 434fb80d49
23 changed files with 395 additions and 71 deletions

View File

@@ -515,12 +515,20 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
@protected
void cst_api_fill_to_wire_liquid_sdk_error(LiquidSdkError apiObj, wire_cst_liquid_sdk_error wireObj) {
if (apiObj is LiquidSdkError_AlreadyStarted) {
wireObj.tag = 0;
return;
}
if (apiObj is LiquidSdkError_Generic) {
var pre_err = cst_encode_String(apiObj.err);
wireObj.tag = 0;
wireObj.tag = 1;
wireObj.kind.Generic.err = pre_err;
return;
}
if (apiObj is LiquidSdkError_NotStarted) {
wireObj.tag = 2;
return;
}
}
@protected
@@ -941,6 +949,22 @@ class RustLibWire implements BaseWire {
_wire__crate__bindings__BindingLiquidSdk_backupPtr
.asFunction<void Function(int, int, ffi.Pointer<wire_cst_backup_request>)>();
void wire__crate__bindings__BindingLiquidSdk_disconnect(
int port_,
int that,
) {
return _wire__crate__bindings__BindingLiquidSdk_disconnect(
port_,
that,
);
}
late final _wire__crate__bindings__BindingLiquidSdk_disconnectPtr =
_lookup<ffi.NativeFunction<ffi.Void Function(ffi.Int64, ffi.UintPtr)>>(
'frbgen_breez_liquid_wire__crate__bindings__BindingLiquidSdk_disconnect');
late final _wire__crate__bindings__BindingLiquidSdk_disconnect =
_wire__crate__bindings__BindingLiquidSdk_disconnectPtr.asFunction<void Function(int, int)>();
void wire__crate__bindings__BindingLiquidSdk_empty_wallet_cache(
int port_,
int that,