Skip to content

Commit 672379c

Browse files
committed
Refactor persistance related IO to separate module.
1 parent 9241a4a commit 672379c

File tree

8 files changed

+20
-17
lines changed

8 files changed

+20
-17
lines changed

ldk-server/src/api/list_forwarded_payments.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::api::error::LdkServerError;
22
use crate::api::error::LdkServerErrorCode::InternalServerError;
3-
use crate::io::{
3+
use crate::io::persist::{
44
FORWARDED_PAYMENTS_PERSISTENCE_PRIMARY_NAMESPACE,
55
FORWARDED_PAYMENTS_PERSISTENCE_SECONDARY_NAMESPACE,
66
};

ldk-server/src/api/list_payments.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
use crate::api::error::LdkServerError;
22
use crate::api::error::LdkServerErrorCode::InternalServerError;
3-
use crate::io::{PAYMENTS_PERSISTENCE_PRIMARY_NAMESPACE, PAYMENTS_PERSISTENCE_SECONDARY_NAMESPACE};
3+
use crate::io::persist::{
4+
PAYMENTS_PERSISTENCE_PRIMARY_NAMESPACE, PAYMENTS_PERSISTENCE_SECONDARY_NAMESPACE,
5+
};
46
use crate::service::Context;
57
use bytes::Bytes;
68
use ldk_server_protos::api::{ListPaymentsRequest, ListPaymentsResponse};

ldk-server/src/io/mod.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,2 @@
1-
pub(crate) mod paginated_kv_store;
2-
pub(crate) mod sqlite_store;
1+
pub(crate) mod persist;
32
pub(crate) mod utils;
4-
5-
/// The forwarded payments will be persisted under this prefix.
6-
pub(crate) const FORWARDED_PAYMENTS_PERSISTENCE_PRIMARY_NAMESPACE: &str = "forwarded_payments";
7-
pub(crate) const FORWARDED_PAYMENTS_PERSISTENCE_SECONDARY_NAMESPACE: &str = "";
8-
9-
/// The payments will be persisted under this prefix.
10-
pub(crate) const PAYMENTS_PERSISTENCE_PRIMARY_NAMESPACE: &str = "payments";
11-
pub(crate) const PAYMENTS_PERSISTENCE_SECONDARY_NAMESPACE: &str = "";

ldk-server/src/io/persist/mod.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
pub(crate) mod paginated_kv_store;
2+
pub(crate) mod sqlite_store;
3+
4+
/// The forwarded payments will be persisted under this prefix.
5+
pub(crate) const FORWARDED_PAYMENTS_PERSISTENCE_PRIMARY_NAMESPACE: &str = "forwarded_payments";
6+
pub(crate) const FORWARDED_PAYMENTS_PERSISTENCE_SECONDARY_NAMESPACE: &str = "";
7+
8+
/// The payments will be persisted under this prefix.
9+
pub(crate) const PAYMENTS_PERSISTENCE_PRIMARY_NAMESPACE: &str = "payments";
10+
pub(crate) const PAYMENTS_PERSISTENCE_SECONDARY_NAMESPACE: &str = "";

ldk-server/src/io/sqlite_store/mod.rs renamed to ldk-server/src/io/persist/sqlite_store/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::io::paginated_kv_store::{ListResponse, PaginatedKVStore};
1+
use crate::io::persist::paginated_kv_store::{ListResponse, PaginatedKVStore};
22
use crate::io::utils::check_namespace_key_validity;
33
use ldk_node::lightning::types::string::PrintableString;
44
use rusqlite::{named_params, Connection};

ldk-server/src/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ use tokio::signal::unix::SignalKind;
1313
use hyper::server::conn::http1;
1414
use hyper_util::rt::TokioIo;
1515

16-
use crate::io::paginated_kv_store::PaginatedKVStore;
17-
use crate::io::sqlite_store::SqliteStore;
18-
use crate::io::{
16+
use crate::io::persist::paginated_kv_store::PaginatedKVStore;
17+
use crate::io::persist::sqlite_store::SqliteStore;
18+
use crate::io::persist::{
1919
FORWARDED_PAYMENTS_PERSISTENCE_PRIMARY_NAMESPACE,
2020
FORWARDED_PAYMENTS_PERSISTENCE_SECONDARY_NAMESPACE, PAYMENTS_PERSISTENCE_PRIMARY_NAMESPACE,
2121
PAYMENTS_PERSISTENCE_SECONDARY_NAMESPACE,

ldk-server/src/service.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use crate::api::open_channel::{handle_open_channel, OPEN_CHANNEL_PATH};
3030
use crate::api::update_channel_config::{
3131
handle_update_channel_config_request, UPDATE_CHANNEL_CONFIG_PATH,
3232
};
33-
use crate::io::paginated_kv_store::PaginatedKVStore;
33+
use crate::io::persist::paginated_kv_store::PaginatedKVStore;
3434
use crate::util::proto_adapter::to_error_response;
3535
use std::future::Future;
3636
use std::pin::Pin;

0 commit comments

Comments
 (0)