Skip to content

Commit 30d994a

Browse files
committed
chore: make key optional on PaginationParams
1 parent 4131a98 commit 30d994a

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

crates/tx-cache/src/client.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,10 @@ impl TxCache {
106106
.join(join)
107107
.inspect_err(|e| warn!(%e, "Failed to join URL. Not querying transaction cache."))?;
108108

109-
let request = self.client.get(url).query(&query.map(|q| q.to_query_object()));
109+
let request = self
110+
.client
111+
.get(url)
112+
.query(&query.and_then(|q| q.cursor().map(|c| c.to_query_object())));
110113

111114
// Get the result.
112115
request

crates/tx-cache/src/types.rs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -545,28 +545,22 @@ impl CursorKey for OrderKey {
545545
#[derive(Clone, Debug, Serialize, Deserialize, Default)]
546546
pub struct PaginationParams<C: CursorKey> {
547547
/// The cursor to start from.
548-
cursor: C,
548+
cursor: Option<C>,
549549
}
550550

551551
impl<C: CursorKey> PaginationParams<C> {
552552
/// Creates a new instance of [`PaginationParams`].
553-
pub const fn new(cursor: C) -> Self {
553+
pub const fn new(cursor: Option<C>) -> Self {
554554
Self { cursor }
555555
}
556556

557557
/// Get the cursor to start from.
558-
pub const fn cursor(&self) -> &C {
559-
&self.cursor
558+
pub const fn cursor(&self) -> Option<&C> {
559+
self.cursor.as_ref()
560560
}
561561

562562
/// Consumes the [`PaginationParams`] and returns the cursor.
563-
pub fn into_cursor(self) -> C {
563+
pub fn into_cursor(self) -> Option<C> {
564564
self.cursor
565565
}
566566
}
567-
568-
impl<C: CursorKey> CursorKey for PaginationParams<C> {
569-
fn to_query_object(&self) -> HashMap<String, String> {
570-
self.cursor.to_query_object()
571-
}
572-
}

0 commit comments

Comments
 (0)