chaincodec-stream
Real-time blockchain event streaming for ChainCodec — Tokio-based WebSocket listener with automatic reconnection.
chaincodec-stream connects to an Ethereum JSON-RPC WebSocket endpoint, subscribes to eth_subscribe("logs", filter), and emits RawEvent items through an async channel. The WebSocket connection and resubscription are handled automatically on disconnect.
Features
- Live EVM log streaming — subscribes to
eth_subscribeand emitsRawEventitems - Automatic reconnect — the channel stays open across disconnects; caller never needs to re-subscribe
- Address filtering — subscribe to one or many contract addresses
- Async channels — events arrive via
futures::channel::mpsc, composable with any Tokio runtime - Connection state — query
is_connected()at any time for health checks - Removed log filtering — reorged / removed logs are dropped before reaching your handler
Installation
[]
= "0.1"
= "0.1"
= "0.1"
= { = "1", = ["full"] }
= "0.3"
Quick start
use Arc;
use StreamExt;
use ;
use EvmDecoder;
use MemoryRegistry;
use ;
async
Filter by multiple addresses
let listener = new
.with_addresses;
// Omit .with_address() entirely to receive ALL logs on the chain
let listener_all = new;
Monitor connection health
let listener = new;
let monitor = clone;
spawn;
let mut stream = listener.subscribe.await?;
Compact decode pipeline
while let Some = stream.next.await
Stream error variants
use StreamError;
ConnectionFailed // could not connect
Closed // connection dropped
Timeout // subscription timed out
Decode // decode pipeline error
Other // other runtime error
Ecosystem
| Crate | Purpose |
|---|---|
| chaincodec-core | Traits, types, primitives |
| chaincodec-evm | EVM ABI event & call decoder |
| chaincodec-registry | CSDL schema registry |
| chaincodec-batch | Historical batch decode |
| chaincodec-stream | Live WebSocket event streaming (this crate) |
License
MIT — see LICENSE