Expand description
§HyperSync Network Types
Core network types and query builders for the HyperSync protocol.
This crate provides the fundamental types for constructing queries and handling responses when communicating with HyperSync servers. It supports both JSON and Cap’n Proto serialization formats for efficient network communication.
§Features
- Query builder API: Fluent interface for building complex blockchain queries
- Type-safe filtering: Strongly-typed filters for blocks, transactions, logs, and traces
- Field selection: Choose exactly which data fields to retrieve
- Multiple serialization: Support for JSON and Cap’n Proto protocols
- Validation: Built-in query validation and optimization
§Key Types
Query- Main query builder for specifying blockchain data to retrieveBlockFilter- Filter blocks by number, hash, or other criteriaTransactionFilter- Filter transactions by from/to addresses, value, etc.LogFilter- Filter event logs by contract address, topics, etc.TraceFilter- Filter execution traces by various criteria
§Example
use hypersync_net_types::{Query, LogFilter, LogField};
// Build a query for ERC20 transfer events
let mut query = Query::new().from_block(19000000);
query.to_block = Some(19001000);
query = query.where_logs(
LogFilter::all()
.and_topic0(["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"])?
).select_log_fields([
LogField::Address,
LogField::Topic1,
LogField::Topic2,
LogField::Data,
]);
println!("Query: {:?}", query);Re-exports§
pub use block::BlockField;pub use block::BlockFilter;pub use block::BlockSelection;pub use log::LogField;pub use log::LogFilter;pub use log::LogSelection;pub use query::FieldSelection;pub use query::JoinMode;pub use query::Query;pub use response::ArchiveHeight;pub use response::ChainId;pub use response::RollbackGuard;pub use trace::TraceField;pub use trace::TraceFilter;pub use trace::TraceSelection;pub use transaction::AuthorizationSelection;pub use transaction::TransactionField;pub use transaction::TransactionFilter;pub use transaction::TransactionSelection;pub use types::Sighash;