Skip to content

Commit 4060b62

Browse files
committed
Rename migratable KV store trait for sync API
Prepare the migration API naming for an async variant by giving the existing synchronous trait an explicit Sync suffix. Co-Authored-By: HAL 9000
1 parent 467cd0b commit 4060b62

4 files changed

Lines changed: 9 additions & 9 deletions

File tree

lightning-persister/src/fs_store/v1.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Objects related to [`FilesystemStore`] live here.
22
use crate::fs_store::common::FilesystemStoreState;
33

4-
use lightning::util::persist::{KVStoreSync, MigratableKVStore};
4+
use lightning::util::persist::{KVStoreSync, MigratableKVStoreSync};
55

66
use std::path::PathBuf;
77

@@ -88,7 +88,7 @@ impl KVStore for FilesystemStore {
8888
}
8989
}
9090

91-
impl MigratableKVStore for FilesystemStore {
91+
impl MigratableKVStoreSync for FilesystemStore {
9292
fn list_all_keys(&self) -> Result<Vec<(String, String, String)>, lightning::io::Error> {
9393
self.state.list_all_keys_impl(false)
9494
}

lightning-persister/src/fs_store/v2.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::fs_store::common::{
44
};
55

66
use lightning::util::persist::{
7-
KVStoreSync, MigratableKVStore, PageToken, PaginatedKVStoreSync, PaginatedListResponse,
7+
KVStoreSync, MigratableKVStoreSync, PageToken, PaginatedKVStoreSync, PaginatedListResponse,
88
};
99

1010
use std::fs;
@@ -315,7 +315,7 @@ impl PaginatedKVStore for FilesystemStoreV2 {
315315
}
316316
}
317317

318-
impl MigratableKVStore for FilesystemStoreV2 {
318+
impl MigratableKVStoreSync for FilesystemStoreV2 {
319319
fn list_all_keys(&self) -> Result<Vec<(String, String, String)>, lightning::io::Error> {
320320
self.inner.list_all_keys_impl(true)
321321
}

lightning-persister/src/test_utils.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use lightning::events::ClosureReason;
22
use lightning::ln::functional_test_utils::*;
33
use lightning::util::persist::{
4-
migrate_kv_store_data, read_channel_monitors, KVStoreSync, MigratableKVStore,
4+
migrate_kv_store_data, read_channel_monitors, KVStoreSync, MigratableKVStoreSync,
55
KVSTORE_NAMESPACE_KEY_ALPHABET, KVSTORE_NAMESPACE_KEY_MAX_LEN,
66
};
77
use lightning::util::test_utils;
@@ -59,7 +59,7 @@ pub(crate) fn do_read_write_remove_list_persist<K: KVStoreSync + RefUnwindSafe>(
5959
assert_eq!(listed_keys.len(), 0);
6060
}
6161

62-
pub(crate) fn do_test_data_migration<S: MigratableKVStore, T: MigratableKVStore>(
62+
pub(crate) fn do_test_data_migration<S: MigratableKVStoreSync, T: MigratableKVStoreSync>(
6363
source_store: &mut S, target_store: &mut T,
6464
) {
6565
// We fill the source with some bogus keys.

lightning/src/util/persist.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -554,9 +554,9 @@ pub trait PaginatedKVStore: KVStore {
554554
) -> impl Future<Output = Result<PaginatedListResponse, io::Error>> + 'static + MaybeSend;
555555
}
556556

557-
/// Provides additional interface methods that are required for [`KVStore`]-to-[`KVStore`]
557+
/// Provides additional interface methods that are required for [`KVStoreSync`]-to-[`KVStoreSync`]
558558
/// data migration.
559-
pub trait MigratableKVStore: KVStoreSync {
559+
pub trait MigratableKVStoreSync: KVStoreSync {
560560
/// Returns *all* known keys as a list of `primary_namespace`, `secondary_namespace`, `key` tuples.
561561
///
562562
/// This is useful for migrating data from [`KVStoreSync`] implementation to [`KVStoreSync`]
@@ -575,7 +575,7 @@ pub trait MigratableKVStore: KVStoreSync {
575575
///
576576
/// Will abort and return an error if any IO operation fails. Note that in this case the
577577
/// `target_store` might get left in an intermediate state.
578-
pub fn migrate_kv_store_data<S: MigratableKVStore, T: MigratableKVStore>(
578+
pub fn migrate_kv_store_data<S: MigratableKVStoreSync, T: MigratableKVStoreSync>(
579579
source_store: &mut S, target_store: &mut T,
580580
) -> Result<(), io::Error> {
581581
let keys_to_migrate = source_store.list_all_keys()?;

0 commit comments

Comments
 (0)