Skip to content

Commit 1908f09

Browse files
committed
Rename KVStore trait to KVStoreSync
1 parent dc75436 commit 1908f09

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
@@ -55,7 +55,7 @@ use lightning::sign::EntropySource;
5555
use lightning::sign::OutputSpender;
5656
use lightning::util::logger::Logger;
5757
use lightning::util::persist::{
58-
KVStore, CHANNEL_MANAGER_PERSISTENCE_KEY, CHANNEL_MANAGER_PERSISTENCE_PRIMARY_NAMESPACE,
58+
KVStoreSync, CHANNEL_MANAGER_PERSISTENCE_KEY, CHANNEL_MANAGER_PERSISTENCE_PRIMARY_NAMESPACE,
5959
CHANNEL_MANAGER_PERSISTENCE_SECONDARY_NAMESPACE, NETWORK_GRAPH_PERSISTENCE_KEY,
6060
NETWORK_GRAPH_PERSISTENCE_PRIMARY_NAMESPACE, NETWORK_GRAPH_PERSISTENCE_SECONDARY_NAMESPACE,
6161
SCORER_PERSISTENCE_KEY, SCORER_PERSISTENCE_PRIMARY_NAMESPACE,
@@ -729,8 +729,8 @@ use futures_util::{dummy_waker, OptionalSelector, Selector, SelectorOutput};
729729
/// # impl lightning::util::logger::Logger for Logger {
730730
/// # fn log(&self, _record: lightning::util::logger::Record) {}
731731
/// # }
732-
/// # struct Store {}
733-
/// # impl lightning::util::persist::KVStore for Store {
732+
/// # struct StoreSync {}
733+
/// # impl lightning::util::persist::KVStoreSync for StoreSync {
734734
/// # fn read(&self, primary_namespace: &str, secondary_namespace: &str, key: &str) -> io::Result<Vec<u8>> { Ok(Vec::new()) }
735735
/// # fn write(&self, primary_namespace: &str, secondary_namespace: &str, key: &str, buf: &[u8]) -> io::Result<()> { Ok(()) }
736736
/// # fn remove(&self, primary_namespace: &str, secondary_namespace: &str, key: &str, lazy: bool) -> io::Result<()> { Ok(()) }
@@ -746,14 +746,14 @@ use futures_util::{dummy_waker, OptionalSelector, Selector, SelectorOutput};
746746
/// # fn send_data(&mut self, _data: &[u8], _resume_read: bool) -> usize { 0 }
747747
/// # fn disconnect_socket(&mut self) {}
748748
/// # }
749-
/// # 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>>;
749+
/// # 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>>;
750750
/// # type NetworkGraph = lightning::routing::gossip::NetworkGraph<Arc<Logger>>;
751751
/// # type P2PGossipSync<UL> = lightning::routing::gossip::P2PGossipSync<Arc<NetworkGraph>, Arc<UL>, Arc<Logger>>;
752752
/// # type ChannelManager<B, F, FE> = lightning::ln::channelmanager::SimpleArcChannelManager<ChainMonitor<B, F, FE>, B, FE, Logger>;
753753
/// # 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>;
754754
/// # type LiquidityManager<B, F, FE> = lightning_liquidity::LiquidityManager<Arc<lightning::sign::KeysManager>, Arc<ChannelManager<B, F, FE>>, Arc<F>>;
755755
/// # type Scorer = RwLock<lightning::routing::scoring::ProbabilisticScorer<Arc<NetworkGraph>, Arc<Logger>>>;
756-
/// # type PeerManager<B, F, FE, UL> = lightning::ln::peer_handler::SimpleArcPeerManager<SocketDescriptor, ChainMonitor<B, F, FE>, B, FE, Arc<UL>, Logger, F, Store>;
756+
/// # type PeerManager<B, F, FE, UL> = lightning::ln::peer_handler::SimpleArcPeerManager<SocketDescriptor, ChainMonitor<B, F, FE>, B, FE, Arc<UL>, Logger, F, StoreSync>;
757757
/// #
758758
/// # struct Node<
759759
/// # B: lightning::chain::chaininterface::BroadcasterInterface + Send + Sync + 'static,
@@ -770,10 +770,10 @@ use futures_util::{dummy_waker, OptionalSelector, Selector, SelectorOutput};
770770
/// # liquidity_manager: Arc<LiquidityManager<B, F, FE>>,
771771
/// # chain_monitor: Arc<ChainMonitor<B, F, FE>>,
772772
/// # gossip_sync: Arc<P2PGossipSync<UL>>,
773-
/// # persister: Arc<Store>,
773+
/// # persister: Arc<StoreSync>,
774774
/// # logger: Arc<Logger>,
775775
/// # scorer: Arc<Scorer>,
776-
/// # sweeper: Arc<OutputSweeper<Arc<B>, Arc<D>, Arc<FE>, Arc<F>, Arc<Store>, Arc<Logger>, Arc<O>>>,
776+
/// # sweeper: Arc<OutputSweeper<Arc<B>, Arc<D>, Arc<FE>, Arc<F>, Arc<StoreSync>, Arc<Logger>, Arc<O>>>,
777777
/// # }
778778
/// #
779779
/// # async fn setup_background_processing<
@@ -895,7 +895,7 @@ where
895895
LM::Target: ALiquidityManager,
896896
O::Target: 'static + OutputSpender,
897897
D::Target: 'static + ChangeDestinationSource,
898-
K::Target: 'static + KVStore,
898+
K::Target: 'static + KVStoreSync,
899899
{
900900
let mut should_break = false;
901901
let async_event_handler = |event| {
@@ -1016,21 +1016,21 @@ impl BackgroundProcessor {
10161016
/// documentation].
10171017
///
10181018
/// The thread runs indefinitely unless the object is dropped, [`stop`] is called, or
1019-
/// [`KVStore`] returns an error. In case of an error, the error is retrieved by calling
1019+
/// [`KVStoreSync`] returns an error. In case of an error, the error is retrieved by calling
10201020
/// either [`join`] or [`stop`].
10211021
///
10221022
/// # Data Persistence
10231023
///
1024-
/// [`KVStore`] is responsible for writing out the [`ChannelManager`] to disk, and/or
1024+
/// [`KVStoreSync`] is responsible for writing out the [`ChannelManager`] to disk, and/or
10251025
/// uploading to one or more backup services. See [`ChannelManager::write`] for writing out a
10261026
/// [`ChannelManager`]. See the `lightning-persister` crate for LDK's
10271027
/// provided implementation.
10281028
///
1029-
/// [`KVStore`] is also responsible for writing out the [`NetworkGraph`] to disk, if
1029+
/// [`KVStoreSync`] is also responsible for writing out the [`NetworkGraph`] to disk, if
10301030
/// [`GossipSync`] is supplied. See [`NetworkGraph::write`] for writing out a [`NetworkGraph`].
10311031
/// See the `lightning-persister` crate for LDK's provided implementation.
10321032
///
1033-
/// Typically, users should either implement [`KVStore`] to never return an
1033+
/// Typically, users should either implement [`KVStoreSync`] to never return an
10341034
/// error or call [`join`] and handle any error that may arise. For the latter case,
10351035
/// `BackgroundProcessor` must be restarted by calling `start` again after handling the error.
10361036
///
@@ -1102,7 +1102,7 @@ impl BackgroundProcessor {
11021102
LM::Target: ALiquidityManager,
11031103
D::Target: ChangeDestinationSourceSync,
11041104
O::Target: 'static + OutputSpender,
1105-
K::Target: 'static + KVStore,
1105+
K::Target: 'static + KVStoreSync,
11061106
{
11071107
let stop_thread = Arc::new(AtomicBool::new(false));
11081108
let stop_thread_clone = Arc::clone(&stop_thread);
@@ -1283,7 +1283,8 @@ mod tests {
12831283
use lightning::types::payment::PaymentHash;
12841284
use lightning::util::config::UserConfig;
12851285
use lightning::util::persist::{
1286-
KVStore, CHANNEL_MANAGER_PERSISTENCE_KEY, CHANNEL_MANAGER_PERSISTENCE_PRIMARY_NAMESPACE,
1286+
KVStoreSync, CHANNEL_MANAGER_PERSISTENCE_KEY,
1287+
CHANNEL_MANAGER_PERSISTENCE_PRIMARY_NAMESPACE,
12871288
CHANNEL_MANAGER_PERSISTENCE_SECONDARY_NAMESPACE, NETWORK_GRAPH_PERSISTENCE_KEY,
12881289
NETWORK_GRAPH_PERSISTENCE_PRIMARY_NAMESPACE, NETWORK_GRAPH_PERSISTENCE_SECONDARY_NAMESPACE,
12891290
SCORER_PERSISTENCE_KEY, SCORER_PERSISTENCE_PRIMARY_NAMESPACE,
@@ -1522,7 +1523,7 @@ mod tests {
15221523
}
15231524
}
15241525

1525-
impl KVStore for Persister {
1526+
impl KVStoreSync for Persister {
15261527
fn read(
15271528
&self, primary_namespace: &str, secondary_namespace: &str, key: &str,
15281529
) -> 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
@@ -1829,7 +1829,7 @@ where
18291829
/// - Perform any periodic channel and payment checks by calling [`timer_tick_occurred`] roughly
18301830
/// every minute
18311831
/// - Persist to disk whenever [`get_and_clear_needs_persistence`] returns `true` using a
1832-
/// [`KVStore`] implementation
1832+
/// [`KVStoreSync`] implementation
18331833
/// - Handle [`Event`]s obtained via its [`EventsProvider`] implementation
18341834
///
18351835
/// The [`Future`] returned by [`get_event_or_persistence_needed_future`] is useful in determining
@@ -2411,7 +2411,7 @@ where
24112411
/// [`PeerManager::process_events`]: crate::ln::peer_handler::PeerManager::process_events
24122412
/// [`timer_tick_occurred`]: Self::timer_tick_occurred
24132413
/// [`get_and_clear_needs_persistence`]: Self::get_and_clear_needs_persistence
2414-
/// [`KVStore`]: crate::util::persist::KVStore
2414+
/// [`KVStoreSync`]: crate::util::persist::KVStoreSync
24152415
/// [`get_event_or_persistence_needed_future`]: Self::get_event_or_persistence_needed_future
24162416
/// [`lightning-block-sync`]: https://docs.rs/lightning_block_sync/latest/lightning_block_sync
24172417
/// [`lightning-transaction-sync`]: https://docs.rs/lightning_transaction_sync/latest/lightning_transaction_sync

0 commit comments

Comments
 (0)