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 args = args::Args::parse();
|
||||||
let path = args.i2p_zero_dir;
|
let path = args.i2p_zero_dir;
|
||||||
let output = Command::new(format!("{}/router/bin/tunnel-control.sh", path))
|
let output = Command::new(format!("{}/router/bin/tunnel-control.sh", path))
|
||||||
.args([
|
.args(["socks.create", &format!("{}", get_i2p_socks_proxy_port())])
|
||||||
"socks.create",
|
|
||||||
&format!("{}", get_i2p_socks_proxy_port()),
|
|
||||||
])
|
|
||||||
.spawn()
|
.spawn()
|
||||||
.expect("i2p-zero failed to create a socks proxy tunnel");
|
.expect("i2p-zero failed to create a socks proxy tunnel");
|
||||||
debug!("{:?}", output.stdout);
|
debug!("{:?}", output.stdout);
|
||||||
|
|
|
@ -13,7 +13,10 @@ use log::{
|
||||||
info,
|
info,
|
||||||
warn,
|
warn,
|
||||||
};
|
};
|
||||||
use std::{process::Command, error::Error};
|
use std::{
|
||||||
|
error::Error,
|
||||||
|
process::Command,
|
||||||
|
};
|
||||||
|
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
use std::sync::Mutex;
|
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
|
/// 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());
|
info!("fetching {} transactions", txs_hashes.len());
|
||||||
let host = utils::get_i2p_http_proxy();
|
let host = utils::get_i2p_http_proxy();
|
||||||
let proxy = reqwest::Proxy::http(&host)?;
|
let proxy = reqwest::Proxy::http(&host)?;
|
||||||
|
|
|
@ -190,10 +190,7 @@ pub fn start_core(conn: &Connections) {
|
||||||
];
|
];
|
||||||
if conn.is_i2p_advanced {
|
if conn.is_i2p_advanced {
|
||||||
// set the i2p proxy host for advanced user re-use
|
// set the i2p proxy host for advanced user re-use
|
||||||
std::env::set_var(
|
std::env::set_var(crate::NEVEKO_I2P_PROXY_HOST, &conn.i2p_proxy_host.clone());
|
||||||
crate::NEVEKO_I2P_PROXY_HOST,
|
|
||||||
&conn.i2p_proxy_host.clone(),
|
|
||||||
);
|
|
||||||
std::env::set_var(
|
std::env::set_var(
|
||||||
crate::NEVEKO_I2P_TUNNELS_JSON,
|
crate::NEVEKO_I2P_TUNNELS_JSON,
|
||||||
&conn.i2p_tunnels_json.clone(),
|
&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"));
|
std::env::set_var(crate::NEVEKO_I2P_ADVANCED_MODE, String::from("1"));
|
||||||
}
|
}
|
||||||
if conn.is_remote_node {
|
if conn.is_remote_node {
|
||||||
std::env::set_var(
|
std::env::set_var(crate::MONERO_DAEMON_HOST, &conn.daemon_host.clone());
|
||||||
crate::MONERO_DAEMON_HOST,
|
std::env::set_var(crate::MONERO_WALLET_RPC_HOST, &conn.rpc_host.clone());
|
||||||
&conn.daemon_host.clone(),
|
std::env::set_var(crate::GUI_REMOTE_NODE, crate::GUI_SET_REMOTE_NODE)
|
||||||
);
|
|
||||||
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")
|
let output = std::process::Command::new("./neveko")
|
||||||
.args(args)
|
.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,
|
/// Note, it may take more than one block to do this,
|
||||||
///
|
///
|
||||||
/// especially on stagenet. Over i2p let's cheat and just FFE
|
/// especially on stagenet. Over i2p let's cheat and just FFE
|
||||||
|
///
|
||||||
/// (find first fee).
|
/// (find first fee).
|
||||||
pub async fn estimate_fee() -> u128 {
|
pub async fn estimate_fee() -> u128 {
|
||||||
// loop intializer
|
// loop intializer
|
||||||
|
@ -742,18 +731,18 @@ pub async fn estimate_fee() -> u128 {
|
||||||
let mut count: u64 = 1;
|
let mut count: u64 = 1;
|
||||||
let mut v_fee: Vec<u128> = Vec::new();
|
let mut v_fee: Vec<u128> = Vec::new();
|
||||||
let mut r_height: reqres::XmrDaemonGetHeightResponse = Default::default();
|
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_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);
|
let remote_set = remote_var == String::from(crate::GUI_SET_REMOTE_NODE);
|
||||||
if remote_set {
|
if remote_set {
|
||||||
let p_height = monero::p_get_height().await;
|
let p_height = monero::p_get_height().await;
|
||||||
r_height = p_height.unwrap_or(r_height);
|
r_height = p_height.unwrap_or(r_height);
|
||||||
} else {
|
} else {
|
||||||
r_height = monero::get_height().await;
|
r_height = monero::get_height().await;
|
||||||
}
|
}
|
||||||
if r_height.height == ESTIMATE_FEE_FAILURE as u64 {
|
if r_height.height == ESTIMATE_FEE_FAILURE as u64 {
|
||||||
error!("error fetching height");
|
error!("error fetching height");
|
||||||
return ESTIMATE_FEE_FAILURE;
|
return ESTIMATE_FEE_FAILURE;
|
||||||
}
|
}
|
||||||
loop {
|
loop {
|
||||||
debug!("current height: {}", height);
|
debug!("current height: {}", height);
|
||||||
if v_fee.len() >= 30 {
|
if v_fee.len() >= 30 {
|
||||||
|
|
|
@ -712,6 +712,17 @@ fn send_payment_req(
|
||||||
signature: utils::empty_string(),
|
signature: utils::empty_string(),
|
||||||
};
|
};
|
||||||
log::debug!("creating transaction proof for: {}", &ptxp.hash);
|
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;
|
let get_txp: reqres::XmrRpcGetTxProofResponse = monero::get_tx_proof(ptxp).await;
|
||||||
// TODO(c2m): error handling on failed tx proof generation
|
// TODO(c2m): error handling on failed tx proof generation
|
||||||
// use the signature to create the FINALIZED transaction proof
|
// use the signature to create the FINALIZED transaction proof
|
||||||
|
@ -747,12 +758,6 @@ 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::PROPAGATION_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(
|
||||||
|
|
|
@ -437,14 +437,15 @@ impl eframe::App for HomeApp {
|
||||||
//-------------------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------------------
|
||||||
fn send_xmrd_get_info_req(tx: Sender<reqres::XmrDaemonGetInfoResponse>, ctx: egui::Context) {
|
fn send_xmrd_get_info_req(tx: Sender<reqres::XmrDaemonGetInfoResponse>, ctx: egui::Context) {
|
||||||
tokio::spawn(async move {
|
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) {
|
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 info = p_info.unwrap_or(Default::default());
|
||||||
let _ = tx.send(info);
|
let _ = tx.send(info);
|
||||||
} else {
|
} else {
|
||||||
let info = monero::get_info().await;
|
let info = monero::get_info().await;
|
||||||
let _ = tx.send(info);
|
let _ = tx.send(info);
|
||||||
}
|
}
|
||||||
ctx.request_repaint();
|
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_EXP_DB_KEY: &str = "gui-exp";
|
||||||
pub const GUI_TX_PROOF_DB_KEY: &str = "gui-txp";
|
pub const GUI_TX_PROOF_DB_KEY: &str = "gui-txp";
|
||||||
pub const GUI_NICK_DB_KEY: &str = "gui-nick";
|
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_SIGNATURE_DB_KEY: &str = "gui-txp-sig";
|
||||||
pub const GUI_TX_HASH_DB_KEY: &str = "gui-txp-hash";
|
pub const GUI_TX_HASH_DB_KEY: &str = "gui-txp-hash";
|
||||||
pub const GUI_SIGNED_GPG_DB_KEY: &str = "gui-signed-key";
|
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;
|
pub const BLOCK_TIME_IN_SECS_EST: u64 = 0x78;
|
||||||
/// monero estimated propagation time in seconds
|
/// monero estimated propagation time in seconds
|
||||||
pub const PROPAGATION_TIME_IN_SECS_EST: u64 = 5;
|
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
|
/// 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
|
||||||
|
|
Loading…
Reference in a new issue