mirror of
https://github.com/stakwork/sphinx-key.git
synced 2025-12-17 07:14:23 +01:00
sphinx-key: save previous msgs to sd card
This commit is contained in:
12
Cargo.lock
generated
12
Cargo.lock
generated
@@ -1219,7 +1219,7 @@ checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4"
|
||||
[[package]]
|
||||
name = "lss-connector"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/stakwork/sphinx-rs.git?rev=0d5c40f4087adde7e32e789a88900c5c9ba3b5ab#0d5c40f4087adde7e32e789a88900c5c9ba3b5ab"
|
||||
source = "git+https://github.com/stakwork/sphinx-rs.git?rev=8a4c7acf4c82688b7bc009cbd9b5ced3fbb6c46d#8a4c7acf4c82688b7bc009cbd9b5ced3fbb6c46d"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"log",
|
||||
@@ -1591,7 +1591,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "rmp-utils"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/stakwork/sphinx-rs.git?rev=0d5c40f4087adde7e32e789a88900c5c9ba3b5ab#0d5c40f4087adde7e32e789a88900c5c9ba3b5ab"
|
||||
source = "git+https://github.com/stakwork/sphinx-rs.git?rev=8a4c7acf4c82688b7bc009cbd9b5ced3fbb6c46d#8a4c7acf4c82688b7bc009cbd9b5ced3fbb6c46d"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"log",
|
||||
@@ -1798,7 +1798,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "sphinx-auther"
|
||||
version = "0.1.12"
|
||||
source = "git+https://github.com/stakwork/sphinx-rs.git?rev=0d5c40f4087adde7e32e789a88900c5c9ba3b5ab#0d5c40f4087adde7e32e789a88900c5c9ba3b5ab"
|
||||
source = "git+https://github.com/stakwork/sphinx-rs.git?rev=8a4c7acf4c82688b7bc009cbd9b5ced3fbb6c46d#8a4c7acf4c82688b7bc009cbd9b5ced3fbb6c46d"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"base64 0.21.2",
|
||||
@@ -1810,7 +1810,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "sphinx-crypter"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/stakwork/sphinx-rs.git?rev=0d5c40f4087adde7e32e789a88900c5c9ba3b5ab#0d5c40f4087adde7e32e789a88900c5c9ba3b5ab"
|
||||
source = "git+https://github.com/stakwork/sphinx-rs.git?rev=8a4c7acf4c82688b7bc009cbd9b5ced3fbb6c46d#8a4c7acf4c82688b7bc009cbd9b5ced3fbb6c46d"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"chacha20poly1305",
|
||||
@@ -1821,7 +1821,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "sphinx-glyph"
|
||||
version = "0.1.2"
|
||||
source = "git+https://github.com/stakwork/sphinx-rs.git?rev=0d5c40f4087adde7e32e789a88900c5c9ba3b5ab#0d5c40f4087adde7e32e789a88900c5c9ba3b5ab"
|
||||
source = "git+https://github.com/stakwork/sphinx-rs.git?rev=8a4c7acf4c82688b7bc009cbd9b5ced3fbb6c46d#8a4c7acf4c82688b7bc009cbd9b5ced3fbb6c46d"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"hex",
|
||||
@@ -1872,7 +1872,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "sphinx-signer"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/stakwork/sphinx-rs.git?rev=0d5c40f4087adde7e32e789a88900c5c9ba3b5ab#0d5c40f4087adde7e32e789a88900c5c9ba3b5ab"
|
||||
source = "git+https://github.com/stakwork/sphinx-rs.git?rev=8a4c7acf4c82688b7bc009cbd9b5ced3fbb6c46d#8a4c7acf4c82688b7bc009cbd9b5ced3fbb6c46d"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"bip39",
|
||||
|
||||
@@ -19,11 +19,11 @@ serde_json = { version = "1.0.81", default-features = false }
|
||||
serde_urlencoded = "0.7.1"
|
||||
url = "2"
|
||||
|
||||
lss-connector = { git = "https://github.com/stakwork/sphinx-rs.git", default-features = false, rev = "0d5c40f4087adde7e32e789a88900c5c9ba3b5ab" }
|
||||
lss-connector = { git = "https://github.com/stakwork/sphinx-rs.git", default-features = false, rev = "8a4c7acf4c82688b7bc009cbd9b5ced3fbb6c46d" }
|
||||
# lss-connector = { path = "../../sphinx-rs/lss-connector", default-features = false }
|
||||
sphinx-crypter = { git = "https://github.com/stakwork/sphinx-rs.git", rev = "0d5c40f4087adde7e32e789a88900c5c9ba3b5ab" }
|
||||
sphinx-crypter = { git = "https://github.com/stakwork/sphinx-rs.git", rev = "8a4c7acf4c82688b7bc009cbd9b5ced3fbb6c46d" }
|
||||
# sphinx-crypter = { path = "../../sphinx-rs/crypter" }
|
||||
sphinx-signer = { git = "https://github.com/stakwork/sphinx-rs.git", optional = true, rev = "0d5c40f4087adde7e32e789a88900c5c9ba3b5ab" }
|
||||
sphinx-signer = { git = "https://github.com/stakwork/sphinx-rs.git", optional = true, rev = "8a4c7acf4c82688b7bc009cbd9b5ced3fbb6c46d" }
|
||||
# sphinx-signer = { path = "../../sphinx-rs/signer", optional = true }
|
||||
|
||||
anyhow.workspace = true
|
||||
|
||||
@@ -144,6 +144,8 @@ pub fn make_event_loop(
|
||||
|
||||
// store the previous msgs processed, for LSS last step
|
||||
let mut msgs: Option<(Vec<u8>, Vec<u8>)> = None;
|
||||
// persist them to sd card in case of crash
|
||||
let msgs_persister = FsPersister::new(&ROOT_STORE, Some(8));
|
||||
|
||||
// signing loop
|
||||
log::info!("=> starting the main signing loop...");
|
||||
@@ -182,6 +184,7 @@ pub fn make_event_loop(
|
||||
} else {
|
||||
// muts! send LSS first!
|
||||
mqtt_pub(&mut mqtt, client_id, topics::LSS_RES, &lss_b);
|
||||
msgs_persister.set_prevs(&vls_b, &lss_b);
|
||||
msgs = Some((vls_b, lss_b));
|
||||
}
|
||||
expected_sequence = Some(sequence + 1);
|
||||
@@ -214,6 +217,14 @@ pub fn make_event_loop(
|
||||
}
|
||||
}
|
||||
Event::LssMessage(msg_bytes) => {
|
||||
if msgs.is_none() {
|
||||
log::warn!("Restoring previous message from sd card");
|
||||
msgs = Some(
|
||||
msgs_persister
|
||||
.read_prevs()
|
||||
.map_err(|e| anyhow::anyhow!("{:?}", e))?,
|
||||
)
|
||||
}
|
||||
match lss::handle_lss_msg(&msg_bytes, msgs, &lss_signer) {
|
||||
Ok((ret_topic, bytes)) => {
|
||||
// set msgs back to None
|
||||
@@ -224,6 +235,8 @@ pub fn make_event_loop(
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
log::error!("LSS MESSAGE FAILED!");
|
||||
log::error!("{}", &e.to_string());
|
||||
msgs = None;
|
||||
let err_msg = GlyphError::new(1, &e.to_string());
|
||||
mqtt_pub(&mut mqtt, client_id, topics::ERROR, &err_msg.to_vec()[..]);
|
||||
|
||||
Reference in New Issue
Block a user