Skip to content

Commit 623eecf

Browse files
committed
fixup! Integrate TierStore into NodeBuilder
- Remove set_backup_storage_dir_path and set_ephemeral_store from ArcedNodeBuilder — these tiered-storage configuration methods belong to the FFI bindings PR (#871) and should not be introduced here. - Gate builder_configures_sqlite_backup_store and sqlite_backup_rejects_primary_storage_path tests behind not exposed through the arced wrapper. - Revert the setup_node_with_builder helper added to test utils: the backup-related test now configures its builder inline, which also removes the &mut Builder requirement that forced setup_builder! to emit mut unconditionally. It's now correctly immutable when uniffi is enabled.
1 parent 309e9ec commit 623eecf

3 files changed

Lines changed: 22 additions & 48 deletions

File tree

src/builder.rs

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1251,38 +1251,6 @@ impl ArcedNodeBuilder {
12511251
self.inner.write().expect("lock").set_wallet_recovery_mode();
12521252
}
12531253

1254-
/// Configures a local SQLite backup store for disaster recovery.
1255-
///
1256-
/// When building with tiered storage, a SQLite store will be created at the
1257-
/// given directory path using [`SQLITE_BACKUP_DB_FILE_NAME`] as its database
1258-
/// file name. It receives a second durable copy of data written to the
1259-
/// primary store.
1260-
///
1261-
/// Writes and removals for primary-backed data only succeed once both the
1262-
/// primary and backup SQLite stores complete successfully.
1263-
///
1264-
/// The configured path must point to a distinct local directory from the
1265-
/// primary storage path. If the backup path equals the primary storage path,
1266-
/// building will fail with [`BuildError::BackupStorePathConflict`].
1267-
///
1268-
/// If not set, durable data will be stored only in the primary store.
1269-
///
1270-
/// [`SQLITE_BACKUP_DB_FILE_NAME`]: crate::io::sqlite_store::SQLITE_BACKUP_DB_FILE_NAME
1271-
pub fn set_backup_storage_dir_path(&self, backup_storage_dir_path: String) {
1272-
self.inner.write().expect("lock").set_backup_storage_dir_path(backup_storage_dir_path);
1273-
}
1274-
1275-
/// Configures the ephemeral store for non-critical, frequently-accessed data.
1276-
///
1277-
/// When building with tiered storage, this store is used for ephemeral data like
1278-
/// the network graph and scorer data to reduce latency for reads. Data stored here
1279-
/// can be rebuilt if lost.
1280-
///
1281-
/// If not set, non-critical data will be stored in the primary store.
1282-
pub fn set_ephemeral_store(&self, ephemeral_store: Arc<DynStore>) {
1283-
self.inner.write().expect("lock").set_ephemeral_store(ephemeral_store);
1284-
}
1285-
12861254
/// Builds a [`Node`] instance with a [`SqliteStore`] backend and according to the options
12871255
/// previously configured.
12881256
pub fn build(&self, node_entropy: Arc<NodeEntropy>) -> Result<Arc<Node>, BuildError> {

tests/common/mod.rs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,9 @@ impl Default for TestConfig {
461461

462462
macro_rules! setup_builder {
463463
($builder:ident, $config:expr) => {
464-
#[allow(unused_mut)]
464+
#[cfg(feature = "uniffi")]
465+
let $builder = Builder::from_config($config.clone());
466+
#[cfg(not(feature = "uniffi"))]
465467
let mut $builder = Builder::from_config($config.clone());
466468
};
467469
}
@@ -529,15 +531,6 @@ pub(crate) fn setup_two_nodes_with_store(
529531
}
530532

531533
pub(crate) fn setup_node(chain_source: &TestChainSource, config: TestConfig) -> TestNode {
532-
setup_node_with_builder(chain_source, config, |_| {})
533-
}
534-
535-
pub(crate) fn setup_node_with_builder<F>(
536-
chain_source: &TestChainSource, config: TestConfig, configure_builder: F,
537-
) -> TestNode
538-
where
539-
F: FnOnce(&mut Builder),
540-
{
541534
setup_builder!(builder, config.node_config);
542535

543536
match chain_source {
@@ -598,8 +591,6 @@ where
598591
builder.set_wallet_recovery_mode();
599592
}
600593

601-
configure_builder(&mut builder);
602-
603594
let node = match config.store_type {
604595
TestStoreType::TestSyncStore => {
605596
let kv_store = TestSyncStore::new(config.node_config.storage_dir_path.into());

tests/integration_tests_rust.rs

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ use electrsd::corepc_node::Node as BitcoinD;
3030
use electrsd::ElectrsD;
3131
use ldk_node::config::{AsyncPaymentsRole, EsploraSyncConfig};
3232
use ldk_node::entropy::NodeEntropy;
33+
#[cfg(not(feature = "uniffi"))]
3334
use ldk_node::io::sqlite_store::SqliteStore;
3435
use ldk_node::liquidity::LSPS2ServiceConfig;
3536
use ldk_node::payment::{
@@ -40,6 +41,7 @@ use ldk_node::{Builder, Event, NodeError};
4041
use lightning::ln::channelmanager::PaymentId;
4142
use lightning::routing::gossip::{NodeAlias, NodeId};
4243
use lightning::routing::router::RouteParametersConfig;
44+
#[cfg(not(feature = "uniffi"))]
4345
use lightning::util::persist::KVStore;
4446
use lightning_invoice::{Bolt11InvoiceDescription, Description};
4547
use lightning_types::payment::{PaymentHash, PaymentPreimage};
@@ -3048,6 +3050,7 @@ async fn splice_in_with_all_balance() {
30483050
node_b.stop().unwrap();
30493051
}
30503052

3053+
#[cfg(not(feature = "uniffi"))]
30513054
#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
30523055
async fn lsps2_multi_lsp_picks_cheapest() {
30533056
do_lsps2_multi_lsp_picks_cheapest(false).await;
@@ -3152,9 +3155,20 @@ async fn builder_configures_sqlite_backup_store() {
31523155
config_a.store_type = TestStoreType::Sqlite;
31533156
let primary_dir = config_a.node_config.storage_dir_path.clone();
31543157
let backup_dir = common::random_storage_path();
3155-
let node_a = common::setup_node_with_builder(&chain_source, config_a.clone(), |builder| {
3156-
builder.set_backup_storage_dir_path(backup_dir.to_str().unwrap().to_owned());
3157-
});
3158+
3159+
// Build node_a with backup storage configured
3160+
setup_builder!(builder_a, config_a.node_config.clone());
3161+
builder_a.set_chain_source_esplora(
3162+
format!("http://{}", electrsd.esplora_url.as_ref().unwrap()),
3163+
None,
3164+
);
3165+
builder_a.set_filesystem_logger(None, None);
3166+
builder_a.set_backup_storage_dir_path(backup_dir.to_str().unwrap().to_owned());
3167+
3168+
let node_a = builder_a.build(config_a.node_entropy.into()).unwrap();
3169+
node_a.start().unwrap();
3170+
assert!(node_a.status().is_running);
3171+
assert!(node_a.status().latest_fee_rate_cache_update_timestamp.is_some());
31583172

31593173
let config_b = random_config(true);
31603174
let node_b = setup_node(&chain_source, config_b);
@@ -3200,14 +3214,15 @@ async fn builder_configures_sqlite_backup_store() {
32003214
}
32013215
}
32023216

3217+
#[cfg(not(feature = "uniffi"))]
32033218
#[test]
32043219
fn sqlite_backup_rejects_primary_storage_path() {
32053220
let mut config = random_config(false);
32063221
config.store_type = TestStoreType::Sqlite;
32073222

32083223
let primary_dir = config.node_config.storage_dir_path.clone();
32093224

3210-
setup_builder!(builder, config.node_config);
3225+
setup_builder!(builder, config.node_config.clone());
32113226
builder.set_backup_storage_dir_path(primary_dir);
32123227

32133228
let res = builder.build(config.node_entropy.into());

0 commit comments

Comments
 (0)