depolymerization

wire gateway for Bitcoin/Ethereum
Log | Files | Refs | Submodules | README | LICENSE

commit 4d23117fdb61298399bb02de21db2abe684f57e5
parent c8f70e92a78ac7249c9f2adab3d617021617bf9f
Author: Antoine A <>
Date:   Wed,  9 Mar 2022 23:55:36 +0100

btc-wire: solve broken pipe errors with config

Diffstat:
MREADME.md | 6+++++-
Mbtc-wire/src/btc_config.rs | 2+-
Mbtc-wire/src/rpc.rs | 11+----------
3 files changed, 7 insertions(+), 12 deletions(-)

diff --git a/README.md b/README.md @@ -72,7 +72,7 @@ following currencies are supported: - DEVBTC for regtest network - Ethereum currencies (eth-wire): - ETHEREUMETH for main network - - TESTROPSTENETH for ropsten network + - ROPSTENETH for ropsten network - DEV_ETH for dev network ### btc-wire @@ -85,6 +85,10 @@ the RPC server. Two flags are mandatory: - `maxtxfee=?`: bitcoin transactions fees can exceed taler wire fees, putting your wire in bankruptcy. You must specify an acceptable transaction fee cap. +It is also recommanded to disable RPC client timeout with `rpcclienttimeout=0` +or to set a timeout delay superior than the block delay (e.g +`rpcclienttimeout=720`) to prevent recurrent "Broken pipe" errors. + ```ini [depolymerizer-bitcoin] # Datadir or configuration file path diff --git a/btc-wire/src/btc_config.rs b/btc-wire/src/btc_config.rs @@ -22,7 +22,7 @@ use std::{ use bitcoin::Network; use common::{ currency::CurrencyBtc, - log::{fail, OrFail}, + log::{fail, log::info, OrFail}, }; use crate::{ diff --git a/btc-wire/src/rpc.rs b/btc-wire/src/rpc.rs @@ -31,7 +31,7 @@ use serde_json::{json, Value}; use std::{ fmt::Debug, io::{self, BufRead, BufReader, Write}, - net::{SocketAddr, TcpStream}, + net::TcpStream, time::{Duration, Instant}, }; @@ -115,7 +115,6 @@ const EMPTY: [(); 0] = []; /// Bitcoin RPC connection pub struct Rpc { last_call: Instant, - addr: SocketAddr, path: String, id: u64, cookie: String, @@ -150,7 +149,6 @@ impl Rpc { Ok(Self { last_call: Instant::now(), - addr: config.addr, path, id: 0, cookie: format!("Basic {}", base64::encode(token)), @@ -163,13 +161,6 @@ impl Rpc { where T: serde::de::DeserializeOwned + Debug, { - // Handle bitcoind RPC client timeout - if self.last_call.elapsed() > Duration::from_secs(30) { - // Create new connection - let sock = TcpStream::connect_timeout(&self.addr, Duration::from_secs(5))?; - self.conn = BufReader::new(sock); - } - let request = RpcRequest { method, id: self.id,