Document Bitcoin RPC and make it more robust

This commit is contained in:
Luke Parker
2023-03-17 21:25:38 -04:00
parent 9b47ad56bb
commit 0525ba2f62
8 changed files with 64 additions and 13 deletions

View File

@@ -215,8 +215,8 @@ impl PartialEq for Bitcoin {
impl Eq for Bitcoin {}
impl Bitcoin {
pub fn new(url: String) -> Bitcoin {
Bitcoin { rpc: Rpc::new(url) }
pub async fn new(url: String) -> Bitcoin {
Bitcoin { rpc: Rpc::new(url).await.expect("couldn't create a Bitcoin RPC") }
}
#[cfg(test)]

View File

@@ -450,7 +450,7 @@ async fn main() {
let url = env::var("COIN_RPC").expect("coin rpc wasn't specified as an env var");
match env::var("COIN").expect("coin wasn't specified as an env var").as_str() {
#[cfg(feature = "bitcoin")]
"bitcoin" => run(db, Bitcoin::new(url), coordinator).await,
"bitcoin" => run(db, Bitcoin::new(url).await, coordinator).await,
#[cfg(feature = "monero")]
"monero" => run(db, Monero::new(url), coordinator).await,
_ => panic!("unrecognized coin"),

View File

@@ -3,7 +3,7 @@ mod bitcoin {
use crate::coins::Bitcoin;
async fn bitcoin() -> Bitcoin {
let bitcoin = Bitcoin::new("http://serai:seraidex@127.0.0.1:18443".to_string());
let bitcoin = Bitcoin::new("http://serai:seraidex@127.0.0.1:18443".to_string()).await;
bitcoin.fresh_chain().await;
bitcoin
}