update tx propgation wait time for proving payment

This commit is contained in:
creating2morrow 2023-06-12 22:54:13 -04:00
parent 96911d4acd
commit bf7ebaa9c1
3 changed files with 25 additions and 25 deletions

View file

@ -4,9 +4,7 @@ use std::sync::mpsc::{
Sender, Sender,
}; };
use crate::{ use crate::ADD_CONTACT_TIMEOUT_SECS;
ADD_CONTACT_TIMEOUT_SECS,
};
// TODO(c2m): better error handling with and error_tx/error_rx channel // TODO(c2m): better error handling with and error_tx/error_rx channel
// hook into the error thread and show toast messages as required // hook into the error thread and show toast messages as required
@ -359,18 +357,18 @@ impl eframe::App for AddressBookApp {
&& self.status.jwp == utils::empty_string() && self.status.jwp == utils::empty_string()
&& status == "online" && status == "online"
{ {
if ui.button("Prove Retry").clicked() { if ui.button("Prove Retry").clicked() {
send_payment_req( send_payment_req(
self.payment_tx.clone(), self.payment_tx.clone(),
ctx.clone(), ctx.clone(),
Default::default(), Default::default(),
self.status.i2p.clone(), self.status.i2p.clone(),
expire as u64, expire as u64,
true, true,
); );
self.is_loading = true; self.is_loading = true;
}
} }
}
ui.horizontal(|ui| { ui.horizontal(|ui| {
let nick_label = ui.label("nick: "); let nick_label = ui.label("nick: ");
ui.text_edit_singleline(&mut self.add_nick) ui.text_edit_singleline(&mut self.add_nick)
@ -738,6 +736,12 @@ fn send_payment_req(
String::from(&contact), String::from(&contact),
&ftxp.hash &ftxp.hash
); );
// if we made it this far we can now request a JWP from our friend
// wait a bit for the tx to propogate
tokio::time::sleep(std::time::Duration::from_secs(
crate::PROPOGATION_TIME_IN_SECS_EST,
))
.await;
match proof::prove_payment(String::from(&contact), &ftxp).await { match proof::prove_payment(String::from(&contact), &ftxp).await {
Ok(result) => { Ok(result) => {
utils::write_gui_db( utils::write_gui_db(
@ -760,12 +764,6 @@ fn send_payment_req(
_ => log::error!("failed to obtain jwp"), _ => log::error!("failed to obtain jwp"),
} }
monero::close_wallet(&wallet_name, &wallet_password).await; monero::close_wallet(&wallet_name, &wallet_password).await;
// if we made it this far we can now request a JWP from our friend
// wait a bit for the tx to propogate
tokio::time::sleep(std::time::Duration::from_secs(
crate::BLOCK_TIME_IN_SECS_EST,
))
.await;
} }
if retry { if retry {
let k_hash = String::from("gui-txp-hash"); let k_hash = String::from("gui-txp-hash");

View file

@ -261,11 +261,11 @@ impl eframe::App for HomeApp {
ui.text_edit_singleline(&mut self.connections.i2p_zero_dir) ui.text_edit_singleline(&mut self.connections.i2p_zero_dir)
.labelled_by(cm_i2p_dir_label.id); .labelled_by(cm_i2p_dir_label.id);
}); });
let mut is_mainnet = self.connections.mainnet; // let mut is_mainnet = self.connections.mainnet;
if ui.checkbox(&mut is_mainnet, "mainnet").changed() { // if ui.checkbox(&mut is_mainnet, "mainnet").changed() {
self.connections.mainnet = !self.connections.mainnet; // self.connections.mainnet = !self.connections.mainnet;
log::debug!("is mainnet: {}", self.connections.mainnet); // log::debug!("is mainnet: {}", self.connections.mainnet);
} // }
if ui.button("Start/Restart").clicked() { if ui.button("Start/Restart").clicked() {
self.is_editing_connections = false; self.is_editing_connections = false;
utils::kill_child_processes(true); utils::kill_child_processes(true);

View file

@ -13,6 +13,8 @@ pub const LOCK_SCREEN_TIMEOUT_SECS: u64 = 60 * 5;
pub const CRED_CHECK_INTERVAL: u64 = 5; pub const CRED_CHECK_INTERVAL: u64 = 5;
/// monero estimated block time in seconds /// monero estimated block time in seconds
pub const BLOCK_TIME_IN_SECS_EST: u64 = 0x78; pub const BLOCK_TIME_IN_SECS_EST: u64 = 0x78;
/// monero estimated propogation time in seconds
pub const PROPOGATION_TIME_IN_SECS_EST: u64 = 0x1E;
/// time to wait before giving up on adding a contact /// time to wait before giving up on adding a contact
pub const ADD_CONTACT_TIMEOUT_SECS: u64 = 0x5A; pub const ADD_CONTACT_TIMEOUT_SECS: u64 = 0x5A;
/// time to wait before giving up on neveko core /// time to wait before giving up on neveko core