Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: split esplora clients #47

Merged
merged 1 commit into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -558,21 +558,25 @@ fn build_with_store_internal(

let (blockchain, tx_sync, tx_broadcaster, fee_estimator) = match chain_data_source_config {
Some(ChainDataSourceConfig::Esplora(server_url)) => {
log_info!(logger, "Using custom esplora server: {}", server_url);
let mut client_builder = esplora_client::Builder::new(&server_url.clone());
client_builder = client_builder.timeout(DEFAULT_ESPLORA_CLIENT_TIMEOUT_SECS);
let esplora_client = client_builder.build_async().unwrap();

let tx_sync = Arc::new(EsploraSyncClient::from_client(
esplora_client.clone(),
client_builder.clone().build_async().unwrap(),
Arc::clone(&logger),
));
let blockchain = EsploraBlockchain::from_client(esplora_client, BDK_CLIENT_STOP_GAP)
.with_concurrency(BDK_CLIENT_CONCURRENCY);
let blockchain = EsploraBlockchain::from_client(
client_builder.clone().build_async().unwrap(),
BDK_CLIENT_STOP_GAP,
)
.with_concurrency(BDK_CLIENT_CONCURRENCY);
let tx_broadcaster = Arc::new(TransactionBroadcaster::new(
tx_sync.client().clone(),
client_builder.clone().build_async().unwrap(),
Arc::clone(&logger),
));
let fee_estimator = Arc::new(OnchainFeeEstimator::new(
tx_sync.client().clone(),
client_builder.clone().build_async().unwrap(),
Arc::clone(&config),
Arc::clone(&logger),
));
Expand Down
2 changes: 1 addition & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub(crate) const BDK_CLIENT_CONCURRENCY: u8 = 4;
pub(crate) const DEFAULT_ESPLORA_SERVER_URL: &str = "https://blockstream.info/api";

// The default Esplora client timeout we're using.
pub(crate) const DEFAULT_ESPLORA_CLIENT_TIMEOUT_SECS: u64 = 100; // Alby - higher than the sync timeout to avoid deadlocks // 10;
pub(crate) const DEFAULT_ESPLORA_CLIENT_TIMEOUT_SECS: u64 = 10;

// The timeout after which we abandon retrying failed payments.
pub(crate) const LDK_PAYMENT_RETRY_TIMEOUT: Duration = Duration::from_secs(50); // (10);
Expand Down
3 changes: 3 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1338,6 +1338,7 @@ impl Node {
let now = Instant::now();
// We don't add an additional timeout here, as `Wallet::sync` already returns
// after a timeout.
log_info!(sync_logger, "Starting wallet sync");
match wallet.sync().await {
Ok(()) => {
log_info!(
Expand All @@ -1357,6 +1358,7 @@ impl Node {
},
};

log_info!(sync_logger, "Starting fee estimates sync");
let now = Instant::now();
// We don't add an additional timeout here, as
// `FeeEstimator::update_fee_estimates` already returns after a timeout.
Expand All @@ -1379,6 +1381,7 @@ impl Node {
},
}

log_info!(sync_logger, "Starting LDK wallet sync");
let now = Instant::now();
let tx_sync_timeout_fut = tokio::time::timeout(
Duration::from_secs(LDK_WALLET_SYNC_TIMEOUT_SECS),
Expand Down
Loading