signet-tx-cache
What’s in this crate?
- Transaction Pool - Local cache of pending transactions
- Order Book Cache - Indexed storage of active orders
- Event Streaming - Real-time updates as cache state changes
- Query Interface - Fast lookups by various criteria
- Expiration Handling - Automatic cleanup of stale entries
The transaction cache provides a high-performance local view of Signet’s mempool and order book. Instead of making repeated RPC calls, applications can maintain a synchronized cache for instant access to pending transactions and orders.
Key Benefits
Reduced Latency: Query local cache instead of making network requests.
Rich Queries: Filter and sort by multiple attributes efficiently.
Real-time Updates: Subscribe to changes as they happen.
Usage Example
1use signet_tx_cache::{TxCache, CacheConfig, OrderQuery};
2
3// Initialize cache connected to Signet RPC
4let config = CacheConfig::default();
5let cache = TxCache::new(rpc_url, config).await?;
6
7// Start syncing (runs in background)
8cache.start_sync().await?;
9
10// Query orders
11let orders = cache.query_orders(OrderQuery {
12 status: Some(OrderStatus::Open),
13 min_value: Some(1000 * 10^18), // 1000 USD
14 ..Default::default()
15}).await?;
16
17// Subscribe to new orders
18let mut order_stream = cache.subscribe_orders();
19while let Some(order) = order_stream.next().await {
20 println!("New order: {:?}", order);
21}
Essential for applications that need fast access to mempool and order data, like searchers and market makers.