Expand description
Storage layer for Moloch.
Provides persistent storage for:
- Audit events
- Blocks
- MMR nodes
- Indexes for efficient queries
§Batch Operations
For efficient bulk writes, use the batch API:
ⓘ
use moloch_storage::{RocksStorage, StorageBatch, BatchWriter};
let storage = RocksStorage::open("./data")?;
let mut batch = StorageBatch::new();
batch.put_block(block1);
batch.put_block(block2);
batch.put_mmr_node(0, hash);
storage.commit(batch)?; // Atomic write§Iterators
For efficient traversal, use the iterator API:
ⓘ
use moloch_storage::{RocksStorage, BlockIterator, EventIterator};
let storage = RocksStorage::open("./data")?;
// Iterate over all blocks
for block in BlockIterator::all(&storage)? {
println!("Block {}", block?.header.height);
}
// Iterate over events in specific block range
for event in EventIterator::in_blocks(&storage, 0, 100) {
let (height, event) = event?;
println!("Event {} in block {}", event.id(), height);
}Re-exports§
pub use snapshot::ImportPhase;pub use snapshot::ImportProgress;pub use snapshot::PruneConfig;pub use snapshot::PruneStats;pub use snapshot::Snapshot;pub use snapshot::SnapshotBuilder;pub use snapshot::SnapshotError;pub use snapshot::SnapshotHeader;pub use snapshot::SnapshotReader;pub use snapshot::SNAPSHOT_MAGIC;pub use snapshot::SNAPSHOT_VERSION;
Modules§
- snapshot
- Snapshot creation and import for fast sync.
Structs§
- Block
Iterator - Iterator over blocks in a height range.
- Event
Iterator - Iterator over events within a block range.
- Mmap
Config - Configuration for memory-mapped storage.
- Mmap
Stats - Statistics for mmap storage.
- Mmap
Storage - Memory-mapped storage backend.
- MmrNode
Iterator - Iterator over MMR nodes in a position range.
- Rocks
Storage - RocksDB-backed storage.
- Storage
Batch - A batch of operations to commit atomically.
Enums§
- BatchOp
- An operation to include in a batch.
Traits§
- Batch
Writer - Trait for stores that support batch writes.
- Block
Store - Store for blocks.
- Bulk
Reader - Trait for stores that support bulk reads.
- Chain
Store - Combined chain store with MMR support.
- Event
Store - Store for audit events.