Skip to content

Commit d6b7ddd

Browse files
committed
Rename KVStore trait to KVStoreSync
1 parent 90411b1 commit d6b7ddd

File tree

7 files changed

+62
-61
lines changed

7 files changed

+62
-61
lines changed

lightning-background-processor/src/lib.rs

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ use lightning::sign::EntropySource;
4242
use lightning::sign::OutputSpender;
4343
use lightning::util::logger::Logger;
4444
use lightning::util::persist::{
45-
KVStore, CHANNEL_MANAGER_PERSISTENCE_KEY, CHANNEL_MANAGER_PERSISTENCE_PRIMARY_NAMESPACE,
45+
KVStoreSync, CHANNEL_MANAGER_PERSISTENCE_KEY, CHANNEL_MANAGER_PERSISTENCE_PRIMARY_NAMESPACE,
4646
CHANNEL_MANAGER_PERSISTENCE_SECONDARY_NAMESPACE, NETWORK_GRAPH_PERSISTENCE_KEY,
4747
NETWORK_GRAPH_PERSISTENCE_PRIMARY_NAMESPACE, NETWORK_GRAPH_PERSISTENCE_SECONDARY_NAMESPACE,
4848
SCORER_PERSISTENCE_KEY, SCORER_PERSISTENCE_PRIMARY_NAMESPACE,
@@ -690,8 +690,8 @@ use futures_util::{dummy_waker, OptionalSelector, Selector, SelectorOutput};
690690
/// # impl lightning::util::logger::Logger for Logger {
691691
/// # fn log(&self, _record: lightning::util::logger::Record) {}
692692
/// # }
693-
/// # struct Store {}
694-
/// # impl lightning::util::persist::KVStore for Store {
693+
/// # struct StoreSync {}
694+
/// # impl lightning::util::persist::KVStoreSync for StoreSync {
695695
/// # fn read(&self, primary_namespace: &str, secondary_namespace: &str, key: &str) -> io::Result<Vec<u8>> { Ok(Vec::new()) }
696696
/// # fn write(&self, primary_namespace: &str, secondary_namespace: &str, key: &str, buf: &[u8]) -> io::Result<()> { Ok(()) }
697697
/// # fn remove(&self, primary_namespace: &str, secondary_namespace: &str, key: &str, lazy: bool) -> io::Result<()> { Ok(()) }
@@ -707,14 +707,14 @@ use futures_util::{dummy_waker, OptionalSelector, Selector, SelectorOutput};
707707
/// # fn send_data(&mut self, _data: &[u8], _resume_read: bool) -> usize { 0 }
708708
/// # fn disconnect_socket(&mut self) {}
709709
/// # }
710-
/// # type ChainMonitor<B, F, FE> = lightning::chain::chainmonitor::ChainMonitor<lightning::sign::InMemorySigner, Arc<F>, Arc<B>, Arc<FE>, Arc<Logger>, Arc<Store>, Arc<lightning::sign::KeysManager>>;
710+
/// # type ChainMonitor<B, F, FE> = lightning::chain::chainmonitor::ChainMonitor<lightning::sign::InMemorySigner, Arc<F>, Arc<B>, Arc<FE>, Arc<Logger>, Arc<StoreSync>, Arc<lightning::sign::KeysManager>>;
711711
/// # type NetworkGraph = lightning::routing::gossip::NetworkGraph<Arc<Logger>>;
712712
/// # type P2PGossipSync<UL> = lightning::routing::gossip::P2PGossipSync<Arc<NetworkGraph>, Arc<UL>, Arc<Logger>>;
713713
/// # type ChannelManager<B, F, FE> = lightning::ln::channelmanager::SimpleArcChannelManager<ChainMonitor<B, F, FE>, B, FE, Logger>;
714714
/// # type OnionMessenger<B, F, FE> = lightning::onion_message::messenger::OnionMessenger<Arc<lightning::sign::KeysManager>, Arc<lightning::sign::KeysManager>, Arc<Logger>, Arc<ChannelManager<B, F, FE>>, Arc<lightning::onion_message::messenger::DefaultMessageRouter<Arc<NetworkGraph>, Arc<Logger>, Arc<lightning::sign::KeysManager>>>, Arc<ChannelManager<B, F, FE>>, lightning::ln::peer_handler::IgnoringMessageHandler, lightning::ln::peer_handler::IgnoringMessageHandler, lightning::ln::peer_handler::IgnoringMessageHandler>;
715715
/// # type LiquidityManager<B, F, FE> = lightning_liquidity::LiquidityManager<Arc<lightning::sign::KeysManager>, Arc<ChannelManager<B, F, FE>>, Arc<F>>;
716716
/// # type Scorer = RwLock<lightning::routing::scoring::ProbabilisticScorer<Arc<NetworkGraph>, Arc<Logger>>>;
717-
/// # type PeerManager<B, F, FE, UL> = lightning::ln::peer_handler::SimpleArcPeerManager<SocketDescriptor, ChainMonitor<B, F, FE>, B, FE, Arc<UL>, Logger, F, Store>;
717+
/// # type PeerManager<B, F, FE, UL> = lightning::ln::peer_handler::SimpleArcPeerManager<SocketDescriptor, ChainMonitor<B, F, FE>, B, FE, Arc<UL>, Logger, F, StoreSync>;
718718
/// #
719719
/// # struct Node<
720720
/// # B: lightning::chain::chaininterface::BroadcasterInterface + Send + Sync + 'static,
@@ -731,10 +731,10 @@ use futures_util::{dummy_waker, OptionalSelector, Selector, SelectorOutput};
731731
/// # liquidity_manager: Arc<LiquidityManager<B, F, FE>>,
732732
/// # chain_monitor: Arc<ChainMonitor<B, F, FE>>,
733733
/// # gossip_sync: Arc<P2PGossipSync<UL>>,
734-
/// # persister: Arc<Store>,
734+
/// # persister: Arc<StoreSync>,
735735
/// # logger: Arc<Logger>,
736736
/// # scorer: Arc<Scorer>,
737-
/// # sweeper: Arc<OutputSweeper<Arc<B>, Arc<D>, Arc<FE>, Arc<F>, Arc<Store>, Arc<Logger>, Arc<O>>>,
737+
/// # sweeper: Arc<OutputSweeper<Arc<B>, Arc<D>, Arc<FE>, Arc<F>, Arc<StoreSync>, Arc<Logger>, Arc<O>>>,
738738
/// # }
739739
/// #
740740
/// # async fn setup_background_processing<
@@ -856,7 +856,7 @@ where
856856
LM::Target: ALiquidityManager,
857857
O::Target: 'static + OutputSpender,
858858
D::Target: 'static + ChangeDestinationSource,
859-
K::Target: 'static + KVStore,
859+
K::Target: 'static + KVStoreSync,
860860
{
861861
let mut should_break = false;
862862
let async_event_handler = |event| {
@@ -967,21 +967,21 @@ impl BackgroundProcessor {
967967
/// documentation].
968968
///
969969
/// The thread runs indefinitely unless the object is dropped, [`stop`] is called, or
970-
/// [`KVStore`] returns an error. In case of an error, the error is retrieved by calling
970+
/// [`KVStoreSync`] returns an error. In case of an error, the error is retrieved by calling
971971
/// either [`join`] or [`stop`].
972972
///
973973
/// # Data Persistence
974974
///
975-
/// [`KVStore`] is responsible for writing out the [`ChannelManager`] to disk, and/or
975+
/// [`KVStoreSync`] is responsible for writing out the [`ChannelManager`] to disk, and/or
976976
/// uploading to one or more backup services. See [`ChannelManager::write`] for writing out a
977977
/// [`ChannelManager`]. See the `lightning-persister` crate for LDK's
978978
/// provided implementation.
979979
///
980-
/// [`KVStore`] is also responsible for writing out the [`NetworkGraph`] to disk, if
980+
/// [`KVStoreSync`] is also responsible for writing out the [`NetworkGraph`] to disk, if
981981
/// [`GossipSync`] is supplied. See [`NetworkGraph::write`] for writing out a [`NetworkGraph`].
982982
/// See the `lightning-persister` crate for LDK's provided implementation.
983983
///
984-
/// Typically, users should either implement [`KVStore`] to never return an
984+
/// Typically, users should either implement [`KVStoreSync`] to never return an
985985
/// error or call [`join`] and handle any error that may arise. For the latter case,
986986
/// `BackgroundProcessor` must be restarted by calling `start` again after handling the error.
987987
///
@@ -1053,7 +1053,7 @@ impl BackgroundProcessor {
10531053
LM::Target: ALiquidityManager,
10541054
D::Target: ChangeDestinationSourceSync,
10551055
O::Target: 'static + OutputSpender,
1056-
K::Target: 'static + KVStore,
1056+
K::Target: 'static + KVStoreSync,
10571057
{
10581058
let stop_thread = Arc::new(AtomicBool::new(false));
10591059
let stop_thread_clone = Arc::clone(&stop_thread);
@@ -1226,7 +1226,8 @@ mod tests {
12261226
use lightning::types::payment::PaymentHash;
12271227
use lightning::util::config::UserConfig;
12281228
use lightning::util::persist::{
1229-
KVStore, CHANNEL_MANAGER_PERSISTENCE_KEY, CHANNEL_MANAGER_PERSISTENCE_PRIMARY_NAMESPACE,
1229+
KVStoreSync, CHANNEL_MANAGER_PERSISTENCE_KEY,
1230+
CHANNEL_MANAGER_PERSISTENCE_PRIMARY_NAMESPACE,
12301231
CHANNEL_MANAGER_PERSISTENCE_SECONDARY_NAMESPACE, NETWORK_GRAPH_PERSISTENCE_KEY,
12311232
NETWORK_GRAPH_PERSISTENCE_PRIMARY_NAMESPACE, NETWORK_GRAPH_PERSISTENCE_SECONDARY_NAMESPACE,
12321233
SCORER_PERSISTENCE_KEY, SCORER_PERSISTENCE_PRIMARY_NAMESPACE,
@@ -1464,7 +1465,7 @@ mod tests {
14641465
}
14651466
}
14661467

1467-
impl KVStore for Persister {
1468+
impl KVStoreSync for Persister {
14681469
fn read(
14691470
&self, primary_namespace: &str, secondary_namespace: &str, key: &str,
14701471
) -> lightning::io::Result<Vec<u8>> {

lightning-persister/src/fs_store.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
use crate::utils::{check_namespace_key_validity, is_valid_kvstore_str};
33

44
use lightning::types::string::PrintableString;
5-
use lightning::util::persist::{KVStore, MigratableKVStore};
5+
use lightning::util::persist::{KVStoreSync, MigratableKVStore};
66

77
use std::collections::HashMap;
88
use std::fs;
@@ -33,7 +33,7 @@ fn path_to_windows_str<T: AsRef<OsStr>>(path: &T) -> Vec<u16> {
3333
// The number of read/write/remove/list operations after which we clean up our `locks` HashMap.
3434
const GC_LOCK_INTERVAL: usize = 25;
3535

36-
/// A [`KVStore`] implementation that writes to and reads from the file system.
36+
/// A [`KVStoreSync`] implementation that writes to and reads from the file system.
3737
pub struct FilesystemStore {
3838
data_dir: PathBuf,
3939
tmp_file_counter: AtomicUsize,
@@ -92,7 +92,7 @@ impl FilesystemStore {
9292
}
9393
}
9494

95-
impl KVStore for FilesystemStore {
95+
impl KVStoreSync for FilesystemStore {
9696
fn read(
9797
&self, primary_namespace: &str, secondary_namespace: &str, key: &str,
9898
) -> lightning::io::Result<Vec<u8>> {

lightning-persister/src/test_utils.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ use lightning::ln::functional_test_utils::{
44
create_network, create_node_cfgs, create_node_chanmgrs, send_payment,
55
};
66
use lightning::util::persist::{
7-
migrate_kv_store_data, read_channel_monitors, KVStore, MigratableKVStore,
7+
migrate_kv_store_data, read_channel_monitors, KVStoreSync, MigratableKVStore,
88
KVSTORE_NAMESPACE_KEY_ALPHABET, KVSTORE_NAMESPACE_KEY_MAX_LEN,
99
};
1010
use lightning::util::test_utils;
1111
use lightning::{check_added_monitors, check_closed_broadcast, check_closed_event};
1212

1313
use std::panic::RefUnwindSafe;
1414

15-
pub(crate) fn do_read_write_remove_list_persist<K: KVStore + RefUnwindSafe>(kv_store: &K) {
15+
pub(crate) fn do_read_write_remove_list_persist<K: KVStoreSync + RefUnwindSafe>(kv_store: &K) {
1616
let data = [42u8; 32];
1717

1818
let primary_namespace = "testspace";
@@ -113,7 +113,7 @@ pub(crate) fn do_test_data_migration<S: MigratableKVStore, T: MigratableKVStore>
113113

114114
// Integration-test the given KVStore implementation. Test relaying a few payments and check that
115115
// the persisted data is updated the appropriate number of times.
116-
pub(crate) fn do_test_store<K: KVStore + Sync>(store_0: &K, store_1: &K) {
116+
pub(crate) fn do_test_store<K: KVStoreSync + Sync>(store_0: &K, store_1: &K) {
117117
let chanmon_cfgs = create_chanmon_cfgs(2);
118118
let mut node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
119119
let chain_mon_0 = test_utils::TestChainMonitor::new(

lightning/src/ln/channelmanager.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1886,7 +1886,7 @@ where
18861886
/// - Perform any periodic channel and payment checks by calling [`timer_tick_occurred`] roughly
18871887
/// every minute
18881888
/// - Persist to disk whenever [`get_and_clear_needs_persistence`] returns `true` using a
1889-
/// [`KVStore`] implementation
1889+
/// [`KVStoreSync`] implementation
18901890
/// - Handle [`Event`]s obtained via its [`EventsProvider`] implementation
18911891
///
18921892
/// The [`Future`] returned by [`get_event_or_persistence_needed_future`] is useful in determining
@@ -2468,7 +2468,7 @@ where
24682468
/// [`PeerManager::process_events`]: crate::ln::peer_handler::PeerManager::process_events
24692469
/// [`timer_tick_occurred`]: Self::timer_tick_occurred
24702470
/// [`get_and_clear_needs_persistence`]: Self::get_and_clear_needs_persistence
2471-
/// [`KVStore`]: crate::util::persist::KVStore
2471+
/// [`KVStoreSync`]: crate::util::persist::KVStoreSync
24722472
/// [`get_event_or_persistence_needed_future`]: Self::get_event_or_persistence_needed_future
24732473
/// [`lightning-block-sync`]: https://docs.rs/lightning_block_sync/latest/lightning_block_sync
24742474
/// [`lightning-transaction-sync`]: https://docs.rs/lightning_transaction_sync/latest/lightning_transaction_sync

0 commit comments

Comments
 (0)