Skip to content

Commit df77d20

Browse files
committed
Rename KVStore trait to KVStoreSync
1 parent d67bd0f commit df77d20

File tree

8 files changed

+62
-61
lines changed

8 files changed

+62
-61
lines changed

lightning-background-processor/src/lib.rs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ use lightning::sign::ChangeDestinationSourceSync;
4040
use lightning::sign::EntropySource;
4141
use lightning::sign::OutputSpender;
4242
use lightning::util::logger::Logger;
43-
use lightning::util::persist::{KVStore, Persister};
43+
use lightning::util::persist::{KVStoreSync, Persister};
4444
use lightning::util::sweep::OutputSweeper;
4545
#[cfg(feature = "std")]
4646
use lightning::util::sweep::OutputSweeperSync;
@@ -652,8 +652,8 @@ use futures_util::{dummy_waker, OptionalSelector, Selector, SelectorOutput};
652652
/// # impl lightning::util::logger::Logger for Logger {
653653
/// # fn log(&self, _record: lightning::util::logger::Record) {}
654654
/// # }
655-
/// # struct Store {}
656-
/// # impl lightning::util::persist::KVStore for Store {
655+
/// # struct StoreSync {}
656+
/// # impl lightning::util::persist::KVStoreSync for StoreSync {
657657
/// # fn read(&self, primary_namespace: &str, secondary_namespace: &str, key: &str) -> io::Result<Vec<u8>> { Ok(Vec::new()) }
658658
/// # fn write(&self, primary_namespace: &str, secondary_namespace: &str, key: &str, buf: &[u8]) -> io::Result<()> { Ok(()) }
659659
/// # fn remove(&self, primary_namespace: &str, secondary_namespace: &str, key: &str, lazy: bool) -> io::Result<()> { Ok(()) }
@@ -669,22 +669,22 @@ use futures_util::{dummy_waker, OptionalSelector, Selector, SelectorOutput};
669669
/// # fn send_data(&mut self, _data: &[u8], _resume_read: bool) -> usize { 0 }
670670
/// # fn disconnect_socket(&mut self) {}
671671
/// # }
672-
/// # 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>>;
672+
/// # 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>>;
673673
/// # type NetworkGraph = lightning::routing::gossip::NetworkGraph<Arc<Logger>>;
674674
/// # type P2PGossipSync<UL> = lightning::routing::gossip::P2PGossipSync<Arc<NetworkGraph>, Arc<UL>, Arc<Logger>>;
675675
/// # type ChannelManager<B, F, FE> = lightning::ln::channelmanager::SimpleArcChannelManager<ChainMonitor<B, F, FE>, B, FE, Logger>;
676676
/// # 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>;
677677
/// # type LiquidityManager<B, F, FE> = lightning_liquidity::LiquidityManager<Arc<lightning::sign::KeysManager>, Arc<ChannelManager<B, F, FE>>, Arc<F>>;
678678
/// # type Scorer = RwLock<lightning::routing::scoring::ProbabilisticScorer<Arc<NetworkGraph>, Arc<Logger>>>;
679-
/// # type PeerManager<B, F, FE, UL> = lightning::ln::peer_handler::SimpleArcPeerManager<SocketDescriptor, ChainMonitor<B, F, FE>, B, FE, Arc<UL>, Logger, F, Store>;
679+
/// # type PeerManager<B, F, FE, UL> = lightning::ln::peer_handler::SimpleArcPeerManager<SocketDescriptor, ChainMonitor<B, F, FE>, B, FE, Arc<UL>, Logger, F, StoreSync>;
680680
/// #
681681
/// # struct Node<
682682
/// # B: lightning::chain::chaininterface::BroadcasterInterface + Send + Sync + 'static,
683683
/// # F: lightning::chain::Filter + Send + Sync + 'static,
684684
/// # FE: lightning::chain::chaininterface::FeeEstimator + Send + Sync + 'static,
685685
/// # UL: lightning::routing::utxo::UtxoLookup + Send + Sync + 'static,
686686
/// # D: lightning::sign::ChangeDestinationSource + Send + Sync + 'static,
687-
/// # K: lightning::util::persist::KVStore + Send + Sync + 'static,
687+
/// # K: lightning::util::persist::KVStoreSync + Send + Sync + 'static,
688688
/// # O: lightning::sign::OutputSpender + Send + Sync + 'static,
689689
/// # > {
690690
/// # peer_manager: Arc<PeerManager<B, F, FE, UL>>,
@@ -694,7 +694,7 @@ use futures_util::{dummy_waker, OptionalSelector, Selector, SelectorOutput};
694694
/// # liquidity_manager: Arc<LiquidityManager<B, F, FE>>,
695695
/// # chain_monitor: Arc<ChainMonitor<B, F, FE>>,
696696
/// # gossip_sync: Arc<P2PGossipSync<UL>>,
697-
/// # persister: Arc<Store>,
697+
/// # persister: Arc<StoreSync>,
698698
/// # logger: Arc<Logger>,
699699
/// # scorer: Arc<Scorer>,
700700
/// # sweeper: Arc<OutputSweeper<Arc<B>, Arc<D>, Arc<FE>, Arc<F>, Arc<K>, Arc<Logger>, Arc<O>>>,
@@ -706,7 +706,7 @@ use futures_util::{dummy_waker, OptionalSelector, Selector, SelectorOutput};
706706
/// # FE: lightning::chain::chaininterface::FeeEstimator + Send + Sync + 'static,
707707
/// # UL: lightning::routing::utxo::UtxoLookup + Send + Sync + 'static,
708708
/// # D: lightning::sign::ChangeDestinationSource + Send + Sync + 'static,
709-
/// # K: lightning::util::persist::KVStore + Send + Sync + 'static,
709+
/// # K: lightning::util::persist::KVStoreSync + Send + Sync + 'static,
710710
/// # O: lightning::sign::OutputSpender + Send + Sync + 'static,
711711
/// # >(node: Node<B, F, FE, UL, D, K, O>) {
712712
/// let background_persister = Arc::clone(&node.persister);
@@ -822,7 +822,7 @@ where
822822
LM::Target: ALiquidityManager,
823823
O::Target: 'static + OutputSpender,
824824
D::Target: 'static + ChangeDestinationSource,
825-
K::Target: 'static + KVStore,
825+
K::Target: 'static + KVStoreSync,
826826
{
827827
let mut should_break = false;
828828
let async_event_handler = |event| {
@@ -1018,7 +1018,7 @@ impl BackgroundProcessor {
10181018
LM::Target: ALiquidityManager,
10191019
D::Target: ChangeDestinationSourceSync,
10201020
O::Target: 'static + OutputSpender,
1021-
K::Target: 'static + KVStore,
1021+
K::Target: 'static + KVStoreSync,
10221022
{
10231023
let stop_thread = Arc::new(AtomicBool::new(false));
10241024
let stop_thread_clone = Arc::clone(&stop_thread);
@@ -1186,7 +1186,8 @@ mod tests {
11861186
use lightning::types::payment::PaymentHash;
11871187
use lightning::util::config::UserConfig;
11881188
use lightning::util::persist::{
1189-
KVStore, CHANNEL_MANAGER_PERSISTENCE_KEY, CHANNEL_MANAGER_PERSISTENCE_PRIMARY_NAMESPACE,
1189+
KVStoreSync, CHANNEL_MANAGER_PERSISTENCE_KEY,
1190+
CHANNEL_MANAGER_PERSISTENCE_PRIMARY_NAMESPACE,
11901191
CHANNEL_MANAGER_PERSISTENCE_SECONDARY_NAMESPACE, NETWORK_GRAPH_PERSISTENCE_KEY,
11911192
NETWORK_GRAPH_PERSISTENCE_PRIMARY_NAMESPACE, NETWORK_GRAPH_PERSISTENCE_SECONDARY_NAMESPACE,
11921193
SCORER_PERSISTENCE_KEY, SCORER_PERSISTENCE_PRIMARY_NAMESPACE,
@@ -1420,7 +1421,7 @@ mod tests {
14201421
}
14211422
}
14221423

1423-
impl KVStore for Persister {
1424+
impl KVStoreSync for Persister {
14241425
fn read(
14251426
&self, primary_namespace: &str, secondary_namespace: &str, key: &str,
14261427
) -> lightning::io::Result<Vec<u8>> {

lightning-liquidity/tests/common/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use lightning::routing::scoring::{ChannelUsage, ScoreLookUp, ScoreUpdate};
2727
use lightning::sign::{InMemorySigner, KeysManager};
2828
use lightning::util::config::UserConfig;
2929
use lightning::util::persist::{
30-
KVStore, CHANNEL_MANAGER_PERSISTENCE_KEY, CHANNEL_MANAGER_PERSISTENCE_PRIMARY_NAMESPACE,
30+
KVStoreSync, CHANNEL_MANAGER_PERSISTENCE_KEY, CHANNEL_MANAGER_PERSISTENCE_PRIMARY_NAMESPACE,
3131
CHANNEL_MANAGER_PERSISTENCE_SECONDARY_NAMESPACE, NETWORK_GRAPH_PERSISTENCE_KEY,
3232
NETWORK_GRAPH_PERSISTENCE_PRIMARY_NAMESPACE, NETWORK_GRAPH_PERSISTENCE_SECONDARY_NAMESPACE,
3333
SCORER_PERSISTENCE_KEY, SCORER_PERSISTENCE_PRIMARY_NAMESPACE,
@@ -194,7 +194,7 @@ impl Persister {
194194
}
195195
}
196196

197-
impl KVStore for Persister {
197+
impl KVStoreSync for Persister {
198198
fn read(
199199
&self, primary_namespace: &str, secondary_namespace: &str, key: &str,
200200
) -> 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-
/// [`Persister`] such as a [`KVStore`] implementation
1889+
/// [`Persister`] such as a [`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
@@ -2469,7 +2469,7 @@ where
24692469
/// [`timer_tick_occurred`]: Self::timer_tick_occurred
24702470
/// [`get_and_clear_needs_persistence`]: Self::get_and_clear_needs_persistence
24712471
/// [`Persister`]: crate::util::persist::Persister
2472-
/// [`KVStore`]: crate::util::persist::KVStore
2472+
/// [`KVStoreSync`]: crate::util::persist::KVStoreSync
24732473
/// [`get_event_or_persistence_needed_future`]: Self::get_event_or_persistence_needed_future
24742474
/// [`lightning-block-sync`]: https://docs.rs/lightning_block_sync/latest/lightning_block_sync
24752475
/// [`lightning-transaction-sync`]: https://docs.rs/lightning_transaction_sync/latest/lightning_transaction_sync

0 commit comments

Comments
 (0)