mirror of
https://github.com/aljazceru/breez-sdk-liquid.git
synced 2026-01-17 04:54:20 +01:00
feat: add client_id to rt-sync notifications (#747)
This commit is contained in:
54
cli/Cargo.lock
generated
54
cli/Cargo.lock
generated
@@ -777,6 +777,7 @@ dependencies = [
|
||||
"tonic 0.12.3",
|
||||
"tonic-build 0.12.3",
|
||||
"url",
|
||||
"uuid",
|
||||
"x509-parser",
|
||||
"zbase32",
|
||||
]
|
||||
@@ -1220,7 +1221,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e0206e602d2645ec8b24ed8307fadbc6c3110e2b11ab2f806fc02fee49327079"
|
||||
dependencies = [
|
||||
"aes-gcm",
|
||||
"getrandom",
|
||||
"getrandom 0.2.14",
|
||||
"hkdf",
|
||||
"libsecp256k1",
|
||||
"once_cell",
|
||||
@@ -1668,10 +1669,22 @@ dependencies = [
|
||||
"cfg-if",
|
||||
"js-sys",
|
||||
"libc",
|
||||
"wasi",
|
||||
"wasi 0.11.0+wasi-snapshot-preview1",
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "getrandom"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "43a49c392881ce6d5c3b8cb70f98717b7c07aabbdff06687b9030dbfbe2725f8"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"wasi 0.13.3+wasi-0.2.2",
|
||||
"windows-targets 0.52.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ghash"
|
||||
version = "0.5.1"
|
||||
@@ -2655,7 +2668,7 @@ dependencies = [
|
||||
"base64 0.21.7",
|
||||
"elements",
|
||||
"elements-miniscript",
|
||||
"getrandom",
|
||||
"getrandom 0.2.14",
|
||||
"qr_code",
|
||||
"rand",
|
||||
"thiserror 1.0.69",
|
||||
@@ -2818,7 +2831,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2886843bf800fba2e3377cff24abf6379b4c4d5c6681eaf9ea5b0d15090450bd"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"wasi",
|
||||
"wasi 0.11.0+wasi-snapshot-preview1",
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
@@ -3395,7 +3408,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a2fe5ef3495d7d2e377ff17b1a8ce2ee2ec2a18cde8b6ad6619d65d0701c135d"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"getrandom",
|
||||
"getrandom 0.2.14",
|
||||
"rand",
|
||||
"ring 0.17.8",
|
||||
"rustc-hash 2.1.0",
|
||||
@@ -3468,7 +3481,7 @@ version = "0.6.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
|
||||
dependencies = [
|
||||
"getrandom",
|
||||
"getrandom 0.2.14",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -3640,7 +3653,7 @@ checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"cfg-if",
|
||||
"getrandom",
|
||||
"getrandom 0.2.14",
|
||||
"libc",
|
||||
"spin 0.9.8",
|
||||
"untrusted 0.9.0",
|
||||
@@ -4965,6 +4978,15 @@ version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
|
||||
|
||||
[[package]]
|
||||
name = "uuid"
|
||||
version = "1.13.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ced87ca4be083373936a67f8de945faa23b6b42384bd5b64434850802c6dccd0"
|
||||
dependencies = [
|
||||
"getrandom 0.3.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "vcpkg"
|
||||
version = "0.2.15"
|
||||
@@ -5002,6 +5024,15 @@ version = "0.11.0+wasi-snapshot-preview1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
|
||||
|
||||
[[package]]
|
||||
name = "wasi"
|
||||
version = "0.13.3+wasi-0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "26816d2e1a4a36a2940b96c5296ce403917633dff8f3440e9b236ed6f6bacad2"
|
||||
dependencies = [
|
||||
"wit-bindgen-rt",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen"
|
||||
version = "0.2.99"
|
||||
@@ -5384,6 +5415,15 @@ dependencies = [
|
||||
"windows-sys 0.48.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wit-bindgen-rt"
|
||||
version = "0.33.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3268f3d866458b787f390cf61f4bbb563b922d091359f9608842999eaee3943c"
|
||||
dependencies = [
|
||||
"bitflags 2.6.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "write16"
|
||||
version = "1.0.0"
|
||||
|
||||
@@ -61,11 +61,11 @@ ecies = { version = "0.2.7", default-features = false, features = ["pure"] }
|
||||
semver = "1.0.23"
|
||||
lazy_static = "1.5.0"
|
||||
tonic = { version = "0.12.3", features = ["tls", "tls-webpki-roots"] }
|
||||
uuid = { version = "1.8.0", features = ["v4"] }
|
||||
|
||||
[dev-dependencies]
|
||||
paste = "1.0.15"
|
||||
tempdir = "0.3.7"
|
||||
uuid = { version = "1.8.0", features = ["v4"] }
|
||||
|
||||
[build-dependencies]
|
||||
anyhow = { version = "1.0.79", features = ["backtrace"] }
|
||||
|
||||
@@ -31,6 +31,7 @@ pub(crate) mod model;
|
||||
|
||||
pub(crate) struct SyncService {
|
||||
remote_url: String,
|
||||
client_id: String,
|
||||
persister: Arc<Persister>,
|
||||
recoverer: Arc<Recoverer>,
|
||||
signer: Arc<Box<dyn Signer>>,
|
||||
@@ -45,7 +46,10 @@ impl SyncService {
|
||||
signer: Arc<Box<dyn Signer>>,
|
||||
client: Box<dyn SyncerClient>,
|
||||
) -> Self {
|
||||
let client_id = uuid::Uuid::new_v4().to_string();
|
||||
|
||||
Self {
|
||||
client_id,
|
||||
remote_url,
|
||||
persister,
|
||||
recoverer,
|
||||
@@ -126,7 +130,13 @@ impl SyncService {
|
||||
Some(msg) = remote_sync_trigger.next() => {
|
||||
log::info!("realtime-sync: Received remote message");
|
||||
match msg {
|
||||
Ok(_) => self.run_event_loop().await,
|
||||
Ok(Notification { client_id }) => {
|
||||
if client_id.is_some_and(|id| id == self.client_id) {
|
||||
log::info!("realtime-sync: Notification client_id matches our own, skipping update.");
|
||||
continue;
|
||||
}
|
||||
self.run_event_loop().await;
|
||||
}
|
||||
Err(err) => {
|
||||
log::warn!("realtime-sync: Received status {} from remote, attempting to reconnect.", err.message());
|
||||
break; // break the inner loop which will start the main loop by reconnecting
|
||||
@@ -436,7 +446,12 @@ impl SyncService {
|
||||
trace!("Got record: {record:?}");
|
||||
|
||||
// Step 4: Push the record
|
||||
let req = SetRecordRequest::new(record, utils::now(), self.signer.clone())?;
|
||||
let req = SetRecordRequest::new(
|
||||
record,
|
||||
utils::now(),
|
||||
self.signer.clone(),
|
||||
self.client_id.clone(),
|
||||
)?;
|
||||
trace!("Got set record request: {req:?}");
|
||||
let reply = self.client.push(req).await?;
|
||||
trace!("Got reply: {reply:?}");
|
||||
|
||||
@@ -40,6 +40,7 @@ impl SetRecordRequest {
|
||||
record: Record,
|
||||
request_time: u32,
|
||||
signer: Arc<Box<dyn Signer>>,
|
||||
client_id: String,
|
||||
) -> Result<Self, SignerError> {
|
||||
let msg = format!(
|
||||
"{}-{}-{}-{}-{}",
|
||||
@@ -56,6 +57,7 @@ impl SetRecordRequest {
|
||||
record: Some(record),
|
||||
request_time,
|
||||
signature,
|
||||
client_id: Some(client_id),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ message SetRecordRequest {
|
||||
Record record = 1;
|
||||
uint32 request_time = 2;
|
||||
string signature = 3;
|
||||
optional string client_id = 4;
|
||||
}
|
||||
enum SetRecordStatus {
|
||||
SUCCESS = 0;
|
||||
@@ -42,4 +43,4 @@ message ListenChangesRequest {
|
||||
string signature = 2;
|
||||
}
|
||||
|
||||
message Notification {}
|
||||
message Notification { optional string client_id = 1; }
|
||||
|
||||
Reference in New Issue
Block a user