Skip to content

Commit efc9e36

Browse files
committed
Remove blocking KV store support
Drop the remaining synchronous KV store trait bounds and implementations. After the preceding migrations, custom stores only need to provide async KVStore persistence. Co-Authored-By: HAL 9000
1 parent e245fc0 commit efc9e36

10 files changed

Lines changed: 339 additions & 715 deletions

File tree

src/builder.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ use crate::tx_broadcaster::TransactionBroadcaster;
8181
use crate::types::{
8282
AsyncPersister, ChainMonitor, ChannelManager, DynStore, DynStoreRef, DynStoreWrapper,
8383
GossipSync, Graph, HRNResolver, KeysManager, MessageRouter, OnionMessenger, PaymentStore,
84-
PeerManager, PendingPaymentStore, SyncAndAsyncKVStore,
84+
PeerManager, PendingPaymentStore,
8585
};
8686
use crate::wallet::persist::KVStoreWalletPersister;
8787
use crate::wallet::Wallet;
@@ -176,17 +176,17 @@ pub enum BuildError {
176176
RuntimeSetupFailed,
177177
/// We failed to read data from the [`KVStore`].
178178
///
179-
/// [`KVStore`]: lightning::util::persist::KVStoreSync
179+
/// [`KVStore`]: lightning::util::persist::KVStore
180180
ReadFailed,
181181
/// We failed to write data to the [`KVStore`].
182182
///
183-
/// [`KVStore`]: lightning::util::persist::KVStoreSync
183+
/// [`KVStore`]: lightning::util::persist::KVStore
184184
WriteFailed,
185185
/// We failed to access the given `storage_dir_path`.
186186
StoragePathAccessFailed,
187187
/// We failed to setup our [`KVStore`].
188188
///
189-
/// [`KVStore`]: lightning::util::persist::KVStoreSync
189+
/// [`KVStore`]: lightning::util::persist::KVStore
190190
KVStoreSetupFailed,
191191
/// We failed to setup the onchain wallet.
192192
WalletSetupFailed,
@@ -826,7 +826,7 @@ impl NodeBuilder {
826826
}
827827

828828
/// Builds a [`Node`] instance according to the options previously configured.
829-
pub fn build_with_store<S: SyncAndAsyncKVStore + Send + Sync + 'static>(
829+
pub fn build_with_store<S: KVStore + Send + Sync + 'static>(
830830
&self, node_entropy: NodeEntropy, kv_store: S,
831831
) -> Result<Node, BuildError> {
832832
let logger = setup_logger(&self.log_writer_config, &self.config)?;
@@ -845,14 +845,14 @@ impl NodeBuilder {
845845
}
846846
}
847847

848-
fn build_with_store_and_logger<S: SyncAndAsyncKVStore + Send + Sync + 'static>(
848+
fn build_with_store_and_logger<S: KVStore + Send + Sync + 'static>(
849849
&self, node_entropy: NodeEntropy, kv_store: S, logger: Arc<Logger>,
850850
) -> Result<Node, BuildError> {
851851
let runtime = self.setup_runtime(&logger)?;
852852
self.build_with_store_runtime_and_logger(node_entropy, kv_store, runtime, logger)
853853
}
854854

855-
fn build_with_store_runtime_and_logger<S: SyncAndAsyncKVStore + Send + Sync + 'static>(
855+
fn build_with_store_runtime_and_logger<S: KVStore + Send + Sync + 'static>(
856856
&self, node_entropy: NodeEntropy, kv_store: S, runtime: Arc<Runtime>, logger: Arc<Logger>,
857857
) -> Result<Node, BuildError> {
858858
let seed_bytes = node_entropy.to_seed_bytes();
@@ -1346,7 +1346,7 @@ impl ArcedNodeBuilder {
13461346
/// Builds a [`Node`] instance according to the options previously configured.
13471347
// Note that the generics here don't actually work for Uniffi, but we don't currently expose
13481348
// this so its not needed.
1349-
pub fn build_with_store<S: SyncAndAsyncKVStore + Send + Sync + 'static>(
1349+
pub fn build_with_store<S: KVStore + Send + Sync + 'static>(
13501350
&self, node_entropy: Arc<NodeEntropy>, kv_store: S,
13511351
) -> Result<Arc<Node>, BuildError> {
13521352
self.inner.read().expect("lock").build_with_store(*node_entropy, kv_store).map(Arc::new)

src/io/in_memory_store.rs

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ use std::sync::atomic::{AtomicU64, Ordering};
1111
use std::sync::Mutex;
1212

1313
use lightning::io;
14-
use lightning::util::persist::{
15-
KVStore, KVStoreSync, PageToken, PaginatedKVStore, PaginatedKVStoreSync, PaginatedListResponse,
16-
};
14+
use lightning::util::persist::{KVStore, PageToken, PaginatedKVStore, PaginatedListResponse};
1715

1816
const IN_MEMORY_PAGE_SIZE: usize = 50;
1917

@@ -128,30 +126,6 @@ impl KVStore for InMemoryStore {
128126
}
129127
}
130128

131-
impl KVStoreSync for InMemoryStore {
132-
fn read(
133-
&self, primary_namespace: &str, secondary_namespace: &str, key: &str,
134-
) -> io::Result<Vec<u8>> {
135-
self.read_internal(primary_namespace, secondary_namespace, key)
136-
}
137-
138-
fn write(
139-
&self, primary_namespace: &str, secondary_namespace: &str, key: &str, buf: Vec<u8>,
140-
) -> io::Result<()> {
141-
self.write_internal(primary_namespace, secondary_namespace, key, buf)
142-
}
143-
144-
fn remove(
145-
&self, primary_namespace: &str, secondary_namespace: &str, key: &str, lazy: bool,
146-
) -> io::Result<()> {
147-
self.remove_internal(primary_namespace, secondary_namespace, key, lazy)
148-
}
149-
150-
fn list(&self, primary_namespace: &str, secondary_namespace: &str) -> io::Result<Vec<String>> {
151-
self.list_internal(primary_namespace, secondary_namespace)
152-
}
153-
}
154-
155129
impl InMemoryStore {
156130
fn list_paginated_internal(
157131
&self, primary_namespace: &str, secondary_namespace: &str, page_token: Option<PageToken>,
@@ -202,14 +176,6 @@ impl InMemoryStore {
202176
}
203177
}
204178

205-
impl PaginatedKVStoreSync for InMemoryStore {
206-
fn list_paginated(
207-
&self, primary_namespace: &str, secondary_namespace: &str, page_token: Option<PageToken>,
208-
) -> io::Result<PaginatedListResponse> {
209-
self.list_paginated_internal(primary_namespace, secondary_namespace, page_token)
210-
}
211-
}
212-
213179
impl PaginatedKVStore for InMemoryStore {
214180
fn list_paginated(
215181
&self, primary_namespace: &str, secondary_namespace: &str, page_token: Option<PageToken>,

0 commit comments

Comments
 (0)