Skip to main content

Crate moloch_storage

Crate moloch_storage 

Source
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§

BlockIterator
Iterator over blocks in a height range.
EventIterator
Iterator over events within a block range.
MmapConfig
Configuration for memory-mapped storage.
MmapStats
Statistics for mmap storage.
MmapStorage
Memory-mapped storage backend.
MmrNodeIterator
Iterator over MMR nodes in a position range.
RocksStorage
RocksDB-backed storage.
StorageBatch
A batch of operations to commit atomically.

Enums§

BatchOp
An operation to include in a batch.

Traits§

BatchWriter
Trait for stores that support batch writes.
BlockStore
Store for blocks.
BulkReader
Trait for stores that support bulk reads.
ChainStore
Combined chain store with MMR support.
EventStore
Store for audit events.