Skip to content

Commit 31026d6

Browse files
authored
Merge pull request #23 from G8XSU/sqlite-paginated-impl
Add Sqlite based PaginatedKVStore impl.
2 parents ecfe4cc + 7eab8bf commit 31026d6

File tree

6 files changed

+551
-3
lines changed

6 files changed

+551
-3
lines changed

Cargo.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ldk-server/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,7 @@ prost = { version = "0.11.6", default-features = false, features = ["std"] }
1515
ldk-server-protos = { path = "../ldk-server-protos" }
1616
bytes = "1.4.0"
1717
hex = { package = "hex-conservative", version = "0.2.1", default-features = false }
18+
rusqlite = { version = "0.28.0", features = ["bundled"] }
19+
20+
[dev-dependencies]
21+
rand = "0.8.5"

ldk-server/src/io/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
pub(crate) mod paginated_kv_store;
2+
pub(crate) mod sqlite_store;
3+
pub(crate) mod utils;

ldk-server/src/io/paginated_kv_store.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ pub trait PaginatedKVStore {
7272
/// `primary_namespace`, ordered in descending order of `time`.
7373
///
7474
/// The `list` method returns the latest records first, based on the `time` associated with each key.
75-
/// Pagination is controlled by the `next_page_token`, which is an `Option<String>`
75+
/// Pagination is controlled by the `next_page_token`, which is an `Option<(String, i64)>`
7676
/// used to determine the starting point for the next page of results. If `next_page_token` is `None`,
7777
/// the listing starts from the most recent entry. The `next_page_token` in the returned
7878
/// [`ListResponse`] can be used to fetch the next page of results.
@@ -85,7 +85,8 @@ pub trait PaginatedKVStore {
8585
///
8686
/// [`ListResponse`]: struct.ListResponse.html
8787
fn list(
88-
&self, primary_namespace: &str, secondary_namespace: &str, next_page_token: Option<String>,
88+
&self, primary_namespace: &str, secondary_namespace: &str,
89+
next_page_token: Option<(String, i64)>,
8990
) -> Result<ListResponse, io::Error>;
9091
}
9192

@@ -98,5 +99,5 @@ pub struct ListResponse {
9899
pub keys: Vec<String>,
99100

100101
/// A token that can be used to retrieve the next set of keys.
101-
pub next_page_token: Option<String>,
102+
pub next_page_token: Option<(String, i64)>,
102103
}

0 commit comments

Comments
 (0)