From c0355edc4e40a1858205db6f064c61baf640e98c Mon Sep 17 00:00:00 2001 From: evalir Date: Mon, 9 Mar 2026 19:12:58 +0100 Subject: [PATCH 1/2] feat(perms): add stream_bundles to BuilderTxCache Add a stream_bundles() method that automatically paginates through all bundles, yielding individual CachedBundle items as a Stream. Follows the same unfold+flatten pattern used by upstream TxCache for transactions and orders. Co-Authored-By: Claude Opus 4.6 --- Cargo.toml | 3 ++- src/perms/tx_cache.rs | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 0b96ce5..97c32f4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -56,6 +56,7 @@ async-trait = { version = "0.1.80", optional = true } # AWS aws-config = { version = "1.1.7", optional = true } aws-sdk-kms = { version = "1.15.0", optional = true } +futures-util = { version = "0.3", optional = true } reqwest = { version = "0.12.15", optional = true } rustls = { version = "0.23.31", optional = true } @@ -71,7 +72,7 @@ tokio = { version = "1.43.0", features = ["macros"] } default = ["alloy", "rustls"] alloy = ["dep:alloy"] aws = ["alloy", "alloy?/signer-aws", "dep:async-trait", "dep:aws-config", "dep:aws-sdk-kms"] -perms = ["dep:oauth2", "dep:tokio", "dep:reqwest", "dep:signet-tx-cache"] +perms = ["dep:oauth2", "dep:tokio", "dep:reqwest", "dep:signet-tx-cache", "dep:futures-util"] pylon = ["perms", "alloy/kzg"] block_watcher = ["dep:tokio"] rustls = ["dep:rustls", "rustls/aws-lc-rs"] diff --git a/src/perms/tx_cache.rs b/src/perms/tx_cache.rs index 1cb4902..0b57db1 100644 --- a/src/perms/tx_cache.rs +++ b/src/perms/tx_cache.rs @@ -1,4 +1,6 @@ use crate::perms::oauth::SharedToken; +use futures_util::future::Either; +use futures_util::stream::{self, Stream, StreamExt}; use serde::de::DeserializeOwned; use signet_tx_cache::{ error::TxCacheError, @@ -148,6 +150,24 @@ impl BuilderTxCache { format!("{BUNDLES}/{bundle_id}") } + /// Stream all bundles from the cache, automatically paginating through + /// all available pages. Yields individual [`CachedBundle`] items. + pub fn stream_bundles(&self) -> impl Stream> + Send + '_ { + stream::unfold(Some(None), move |cursor| async move { + let cursor = cursor?; + + match self.get_bundles(cursor).await { + Ok(response) => { + let (inner, next_cursor) = response.into_parts(); + let bundles = stream::iter(inner.bundles).map(Ok); + Some((Either::Left(bundles), next_cursor.map(Some))) + } + Err(error) => Some((Either::Right(stream::once(async { Err(error) })), None)), + } + }) + .flatten() + } + /// Get a bundle from the cache by its UUID. For convenience, this method /// takes a string reference, which is expected to be a valid UUID. #[instrument(skip_all)] From 28664e6351e22e0ffa61180bc8cf3cbc00df2cbe Mon Sep 17 00:00:00 2001 From: evalir Date: Mon, 9 Mar 2026 21:25:32 +0100 Subject: [PATCH 2/2] chore: bump version to 0.18.0-rc.11 Co-Authored-By: Claude Opus 4.6 --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 97c32f4..ce3bfb6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ name = "init4-bin-base" description = "Internal utilities for binaries produced by the init4 team" keywords = ["init4", "bin", "base"] -version = "0.18.0-rc.10" +version = "0.18.0-rc.11" edition = "2021" rust-version = "1.85" authors = ["init4", "James Prestwich", "evalir"]