mirror of
https://github.com/creating2morrow/neveko.git
synced 2024-12-22 19:49:24 +00:00
update tx propagation wait time for i2p remote nodes
This commit is contained in:
parent
74315e1c8b
commit
2f54490333
6 changed files with 44 additions and 44 deletions
|
@ -147,10 +147,7 @@ fn create_socks_proxy_tunnel() {
|
|||
let args = args::Args::parse();
|
||||
let path = args.i2p_zero_dir;
|
||||
let output = Command::new(format!("{}/router/bin/tunnel-control.sh", path))
|
||||
.args([
|
||||
"socks.create",
|
||||
&format!("{}", get_i2p_socks_proxy_port()),
|
||||
])
|
||||
.args(["socks.create", &format!("{}", get_i2p_socks_proxy_port())])
|
||||
.spawn()
|
||||
.expect("i2p-zero failed to create a socks proxy tunnel");
|
||||
debug!("{:?}", output.stdout);
|
||||
|
|
|
@ -13,7 +13,10 @@ use log::{
|
|||
info,
|
||||
warn,
|
||||
};
|
||||
use std::{process::Command, error::Error};
|
||||
use std::{
|
||||
error::Error,
|
||||
process::Command,
|
||||
};
|
||||
|
||||
use lazy_static::lazy_static;
|
||||
use std::sync::Mutex;
|
||||
|
@ -1319,7 +1322,9 @@ pub async fn get_transactions(txs_hashes: Vec<String>) -> reqres::XmrDaemonGetTr
|
|||
}
|
||||
|
||||
/// Performs the xmr daemon 'get_transactions' method for remote daemon
|
||||
pub async fn p_get_transactions(txs_hashes: Vec<String>) -> Result<reqres::XmrDaemonGetTransactionsResponse, Box<dyn Error>> {
|
||||
pub async fn p_get_transactions(
|
||||
txs_hashes: Vec<String>,
|
||||
) -> Result<reqres::XmrDaemonGetTransactionsResponse, Box<dyn Error>> {
|
||||
info!("fetching {} transactions", txs_hashes.len());
|
||||
let host = utils::get_i2p_http_proxy();
|
||||
let proxy = reqwest::Proxy::http(&host)?;
|
||||
|
|
|
@ -190,10 +190,7 @@ pub fn start_core(conn: &Connections) {
|
|||
];
|
||||
if conn.is_i2p_advanced {
|
||||
// set the i2p proxy host for advanced user re-use
|
||||
std::env::set_var(
|
||||
crate::NEVEKO_I2P_PROXY_HOST,
|
||||
&conn.i2p_proxy_host.clone(),
|
||||
);
|
||||
std::env::set_var(crate::NEVEKO_I2P_PROXY_HOST, &conn.i2p_proxy_host.clone());
|
||||
std::env::set_var(
|
||||
crate::NEVEKO_I2P_TUNNELS_JSON,
|
||||
&conn.i2p_tunnels_json.clone(),
|
||||
|
@ -201,18 +198,9 @@ pub fn start_core(conn: &Connections) {
|
|||
std::env::set_var(crate::NEVEKO_I2P_ADVANCED_MODE, String::from("1"));
|
||||
}
|
||||
if conn.is_remote_node {
|
||||
std::env::set_var(
|
||||
crate::MONERO_DAEMON_HOST,
|
||||
&conn.daemon_host.clone(),
|
||||
);
|
||||
std::env::set_var(
|
||||
crate::MONERO_WALLET_RPC_HOST,
|
||||
&conn.rpc_host.clone(),
|
||||
);
|
||||
std::env::set_var(
|
||||
crate::GUI_REMOTE_NODE,
|
||||
crate::GUI_SET_REMOTE_NODE,
|
||||
)
|
||||
std::env::set_var(crate::MONERO_DAEMON_HOST, &conn.daemon_host.clone());
|
||||
std::env::set_var(crate::MONERO_WALLET_RPC_HOST, &conn.rpc_host.clone());
|
||||
std::env::set_var(crate::GUI_REMOTE_NODE, crate::GUI_SET_REMOTE_NODE)
|
||||
}
|
||||
let output = std::process::Command::new("./neveko")
|
||||
.args(args)
|
||||
|
@ -735,6 +723,7 @@ fn validate_installation_hash(sw: ExternalSoftware, filename: &String) -> bool {
|
|||
/// Note, it may take more than one block to do this,
|
||||
///
|
||||
/// especially on stagenet. Over i2p let's cheat and just FFE
|
||||
///
|
||||
/// (find first fee).
|
||||
pub async fn estimate_fee() -> u128 {
|
||||
// loop intializer
|
||||
|
@ -742,18 +731,18 @@ pub async fn estimate_fee() -> u128 {
|
|||
let mut count: u64 = 1;
|
||||
let mut v_fee: Vec<u128> = Vec::new();
|
||||
let mut r_height: reqres::XmrDaemonGetHeightResponse = Default::default();
|
||||
let remote_var = std::env::var(crate::GUI_REMOTE_NODE).unwrap_or(utils::empty_string());
|
||||
let remote_set = remote_var == String::from(crate::GUI_SET_REMOTE_NODE);
|
||||
if remote_set {
|
||||
let p_height = monero::p_get_height().await;
|
||||
r_height = p_height.unwrap_or(r_height);
|
||||
} else {
|
||||
r_height = monero::get_height().await;
|
||||
}
|
||||
if r_height.height == ESTIMATE_FEE_FAILURE as u64 {
|
||||
error!("error fetching height");
|
||||
return ESTIMATE_FEE_FAILURE;
|
||||
}
|
||||
let remote_var = std::env::var(crate::GUI_REMOTE_NODE).unwrap_or(utils::empty_string());
|
||||
let remote_set = remote_var == String::from(crate::GUI_SET_REMOTE_NODE);
|
||||
if remote_set {
|
||||
let p_height = monero::p_get_height().await;
|
||||
r_height = p_height.unwrap_or(r_height);
|
||||
} else {
|
||||
r_height = monero::get_height().await;
|
||||
}
|
||||
if r_height.height == ESTIMATE_FEE_FAILURE as u64 {
|
||||
error!("error fetching height");
|
||||
return ESTIMATE_FEE_FAILURE;
|
||||
}
|
||||
loop {
|
||||
debug!("current height: {}", height);
|
||||
if v_fee.len() >= 30 {
|
||||
|
|
|
@ -712,6 +712,17 @@ fn send_payment_req(
|
|||
signature: utils::empty_string(),
|
||||
};
|
||||
log::debug!("creating transaction proof for: {}", &ptxp.hash);
|
||||
// if we made it this far we can now request a JWP from our friend
|
||||
// wait a bit for the tx to propogate, i2p takes longer
|
||||
let wait = if std::env::var(neveko_core::GUI_REMOTE_NODE)
|
||||
.unwrap_or(utils::empty_string())
|
||||
== String::from(neveko_core::GUI_SET_REMOTE_NODE)
|
||||
{
|
||||
crate::I2P_PROPAGATION_TIME_IN_SECS_EST
|
||||
} else {
|
||||
crate::PROPAGATION_TIME_IN_SECS_EST
|
||||
};
|
||||
tokio::time::sleep(std::time::Duration::from_secs(wait)).await;
|
||||
let get_txp: reqres::XmrRpcGetTxProofResponse = monero::get_tx_proof(ptxp).await;
|
||||
// TODO(c2m): error handling on failed tx proof generation
|
||||
// use the signature to create the FINALIZED transaction proof
|
||||
|
@ -747,12 +758,6 @@ fn send_payment_req(
|
|||
String::from(&contact),
|
||||
&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::PROPAGATION_TIME_IN_SECS_EST,
|
||||
))
|
||||
.await;
|
||||
match proof::prove_payment(String::from(&contact), &ftxp).await {
|
||||
Ok(result) => {
|
||||
utils::write_gui_db(
|
||||
|
|
|
@ -437,14 +437,15 @@ impl eframe::App for HomeApp {
|
|||
//-------------------------------------------------------------------------------------------------
|
||||
fn send_xmrd_get_info_req(tx: Sender<reqres::XmrDaemonGetInfoResponse>, ctx: egui::Context) {
|
||||
tokio::spawn(async move {
|
||||
let remote_var = std::env::var(neveko_core::GUI_REMOTE_NODE).unwrap_or(utils::empty_string());
|
||||
let remote_var =
|
||||
std::env::var(neveko_core::GUI_REMOTE_NODE).unwrap_or(utils::empty_string());
|
||||
if remote_var == String::from(neveko_core::GUI_SET_REMOTE_NODE) {
|
||||
let p_info = monero::p_get_info().await;
|
||||
let p_info = monero::p_get_info().await;
|
||||
let info = p_info.unwrap_or(Default::default());
|
||||
let _ = tx.send(info);
|
||||
} else {
|
||||
let info = monero::get_info().await;
|
||||
let _ = tx.send(info);
|
||||
let info = monero::get_info().await;
|
||||
let _ = tx.send(info);
|
||||
}
|
||||
ctx.request_repaint();
|
||||
});
|
||||
|
|
|
@ -10,6 +10,8 @@ pub const GUI_JWP_DB_KEY: &str = "gui-jwp";
|
|||
pub const GUI_EXP_DB_KEY: &str = "gui-exp";
|
||||
pub const GUI_TX_PROOF_DB_KEY: &str = "gui-txp";
|
||||
pub const GUI_NICK_DB_KEY: &str = "gui-nick";
|
||||
/// Order-Vendor-Lookup for fetching .b32.i2p for order;
|
||||
pub const GUI_OVL_DB_KEY: &str = "gui-ovl";
|
||||
pub const GUI_TX_SIGNATURE_DB_KEY: &str = "gui-txp-sig";
|
||||
pub const GUI_TX_HASH_DB_KEY: &str = "gui-txp-hash";
|
||||
pub const GUI_SIGNED_GPG_DB_KEY: &str = "gui-signed-key";
|
||||
|
@ -36,6 +38,7 @@ pub const CRED_CHECK_INTERVAL: u64 = 5;
|
|||
pub const BLOCK_TIME_IN_SECS_EST: u64 = 0x78;
|
||||
/// monero estimated propagation time in seconds
|
||||
pub const PROPAGATION_TIME_IN_SECS_EST: u64 = 5;
|
||||
pub const I2P_PROPAGATION_TIME_IN_SECS_EST: u64 = PROPAGATION_TIME_IN_SECS_EST * 10;
|
||||
/// time to wait before giving up on adding a contact
|
||||
pub const ADD_CONTACT_TIMEOUT_SECS: u64 = 0x5A;
|
||||
/// time to wait before giving up on neveko core
|
||||
|
|
Loading…
Reference in a new issue