Skip to content

Commit 8297cb4

Browse files
committed
For bitcoind readyness wait 100ms instead of 500ms
1 parent caa7801 commit 8297cb4

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/lib.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ impl BitcoinD {
290290
.spawn()?;
291291

292292
let node_url_default = format!("{}/wallet/default", rpc_url);
293+
let mut i = 0;
293294
// wait bitcoind is ready, use default wallet
294295
let client = loop {
295296
if let Some(status) = process.try_wait()? {
@@ -303,9 +304,10 @@ impl BitcoinD {
303304
return Err(Error::EarlyExit(status));
304305
}
305306
}
306-
thread::sleep(Duration::from_millis(500));
307+
thread::sleep(Duration::from_millis(100));
307308
assert!(process.stderr.is_none());
308309
let client_result = Client::new(&rpc_url, Auth::CookieFile(cookie_file.clone()));
310+
309311
if let Ok(client_base) = client_result {
310312
// RpcApi has get_blockchain_info method, however being generic with `Value` allows
311313
// to be compatible with different version, in the end we are only interested if
@@ -322,6 +324,14 @@ impl BitcoinD {
322324
break Client::new(&node_url_default, Auth::CookieFile(cookie_file.clone()))?;
323325
}
324326
}
327+
328+
debug!(
329+
"bitcoin client for process {} not ready ({})",
330+
process.id(),
331+
i
332+
);
333+
334+
i += 1;
325335
};
326336

327337
Ok(BitcoinD {

0 commit comments

Comments
 (0)