Skip to content

Commit 8dbb312

Browse files
enigbeCopilot
andcommitted
Fix uniffi Builder tiered-storage support in tests
- Make setup_builder! use a mutable binding for Builder under uniffi to preserve test helper compatibility for the FFI-backed builder - Add ArcedNodeBuilder forwarding methods set_backup_storage_dir_path and set_ephemeral_store Co-authored-by: Copilot <copilot@github.com>
1 parent a2458e4 commit 8dbb312

2 files changed

Lines changed: 33 additions & 3 deletions

File tree

src/builder.rs

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

1215+
/// Configures a local SQLite backup store for disaster recovery.
1216+
///
1217+
/// When building with tiered storage, a SQLite store will be created at the
1218+
/// given directory path using [`SQLITE_BACKUP_DB_FILE_NAME`] as its database
1219+
/// file name. It receives a second durable copy of data written to the
1220+
/// primary store.
1221+
///
1222+
/// Writes and removals for primary-backed data only succeed once both the
1223+
/// primary and backup SQLite stores complete successfully.
1224+
///
1225+
/// The configured path must point to a distinct local directory from the
1226+
/// primary storage path. If the backup path equals the primary storage path,
1227+
/// building will fail with [`BuildError::BackupStorePathConflict`].
1228+
///
1229+
/// If not set, durable data will be stored only in the primary store.
1230+
///
1231+
/// [`SQLITE_BACKUP_DB_FILE_NAME`]: crate::io::sqlite_store::SQLITE_BACKUP_DB_FILE_NAME
1232+
pub fn set_backup_storage_dir_path(&self, backup_storage_dir_path: String) {
1233+
self.inner.write().expect("lock").set_backup_storage_dir_path(backup_storage_dir_path);
1234+
}
1235+
1236+
/// Configures the ephemeral store for non-critical, frequently-accessed data.
1237+
///
1238+
/// When building with tiered storage, this store is used for ephemeral data like
1239+
/// the network graph and scorer data to reduce latency for reads. Data stored here
1240+
/// can be rebuilt if lost.
1241+
///
1242+
/// If not set, non-critical data will be stored in the primary store.
1243+
pub fn set_ephemeral_store(&self, ephemeral_store: Arc<DynStore>) {
1244+
self.inner.write().expect("lock").set_ephemeral_store(ephemeral_store);
1245+
}
1246+
12151247
/// Builds a [`Node`] instance with a [`SqliteStore`] backend and according to the options
12161248
/// previously configured.
12171249
pub fn build(&self, node_entropy: Arc<NodeEntropy>) -> Result<Arc<Node>, BuildError> {

tests/common/mod.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -457,9 +457,7 @@ impl Default for TestConfig {
457457

458458
macro_rules! setup_builder {
459459
($builder:ident, $config:expr) => {
460-
#[cfg(feature = "uniffi")]
461-
let $builder = Builder::from_config($config.clone());
462-
#[cfg(not(feature = "uniffi"))]
460+
#[allow(unused_mut)]
463461
let mut $builder = Builder::from_config($config.clone());
464462
};
465463
}

0 commit comments

Comments
 (0)