pub struct MempoolMonitoringClient { /* private fields */ }Expand description
A mempool monitoring client for observing pending transactions.
This client provides methods for acquiring a snapshot of the mempool and iterating through pending transactions.
§Example
use ogmios_client::mempool_monitoring::MempoolMonitoringClient;
use ogmios_client::connection::ConnectionConfig;
let client = MempoolMonitoringClient::connect(ConnectionConfig::default()).await?;
// Acquire mempool snapshot
let slot = client.acquire_mempool().await?;
println!("Acquired mempool at slot {}", slot);
// Get mempool size
let size = client.size_of_mempool().await?;
println!("Mempool has {} transactions ({} bytes)",
size.transactions, size.bytes);
// Iterate through transactions
while let Some(tx) = client.next_transaction().await? {
println!("Transaction: {}", tx.id);
}
// Release when done
client.release_mempool().await?;
client.shutdown().await?;Implementations§
Source§impl MempoolMonitoringClient
impl MempoolMonitoringClient
Sourcepub fn new(context: InteractionContext) -> Self
pub fn new(context: InteractionContext) -> Self
Create a new mempool monitoring client from an existing context.
Sourcepub async fn connect(connection: ConnectionConfig) -> Result<Self>
pub async fn connect(connection: ConnectionConfig) -> Result<Self>
Connect to Ogmios and create a new mempool monitoring client.
§Arguments
connection- Connection configuration.
Sourcepub fn context(&self) -> &InteractionContext
pub fn context(&self) -> &InteractionContext
Get a reference to the interaction context.
Sourcepub async fn acquire_mempool(&self) -> Result<Slot>
pub async fn acquire_mempool(&self) -> Result<Slot>
Sourcepub async fn has_transaction(&self, id: &str) -> Result<bool>
pub async fn has_transaction(&self, id: &str) -> Result<bool>
Sourcepub async fn next_transaction_id(&self) -> Result<Option<TransactionId>>
pub async fn next_transaction_id(&self) -> Result<Option<TransactionId>>
Get the next transaction ID from the mempool.
§Returns
The next transaction ID, or None if the mempool has been exhausted.
Sourcepub async fn next_transaction(&self) -> Result<Option<Transaction>>
pub async fn next_transaction(&self) -> Result<Option<Transaction>>
Get the next full transaction from the mempool.
§Returns
The full transaction, or None if the mempool has been exhausted.
Sourcepub async fn size_of_mempool(&self) -> Result<MempoolSizeAndCapacity>
pub async fn size_of_mempool(&self) -> Result<MempoolSizeAndCapacity>
Get the size and capacity of the mempool.
Sourcepub async fn release_mempool(&self) -> Result<()>
pub async fn release_mempool(&self) -> Result<()>
Release the acquired mempool snapshot.
Auto Trait Implementations§
impl Freeze for MempoolMonitoringClient
impl RefUnwindSafe for MempoolMonitoringClient
impl Send for MempoolMonitoringClient
impl Sync for MempoolMonitoringClient
impl Unpin for MempoolMonitoringClient
impl UnsafeUnpin for MempoolMonitoringClient
impl UnwindSafe for MempoolMonitoringClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more