| Crates.io | montana-local |
| lib.rs | montana-local |
| version | 0.0.1 |
| created_at | 2025-12-16 17:09:07.727556+00 |
| updated_at | 2025-12-16 17:09:07.727556+00 |
| description | Local file-based data source and sink for Montana |
| homepage | https://github.com/base/montana |
| repository | https://github.com/base/montana |
| max_upload_size | |
| id | 1988280 |
| size | 64,487 |
Local file-based data source and sink implementations for Montana.
This crate provides implementations of the pipeline traits that read from and write to local JSON files, useful for testing, debugging, and benchmarking.
LocalBatchSource: Reads L2 block data from a JSON fileLocalBatchSink: Writes compressed batches to a JSON fileNoopCompressor: A passthrough compressor for benchmarkingImplements the BatchSource trait for file-based L2 block data:
use montana_local::LocalBatchSource;
// Load from JSON file
let source = LocalBatchSource::from_file("blocks.json")?;
// Or load from JSON string
let json = r#"{ ... }"#;
let source = LocalBatchSource::from_json(json)?;
JSON Format:
{
"l1_origin": {
"block_number": 12345,
"hash_prefix": "0x0102030405060708091011121314151617181920"
},
"parent_hash": "0x2122232425262728293031323334353637383940",
"blocks": [
{
"timestamp": 1000,
"transactions": [
{"data": "0xf86c0a8502540be400825208"}
]
}
]
}
Implements the BatchSink trait for file-based batch submission:
use montana_local::LocalBatchSink;
// Write to file
let sink = LocalBatchSink::new("output.json");
// Or use in-memory (no file output)
let sink = LocalBatchSink::in_memory();
// With custom capacity
let sink = LocalBatchSink::new("output.json").with_capacity(256 * 1024);
A passthrough compressor for testing and benchmarking:
use montana_local::NoopCompressor;
let compressor = NoopCompressor;
// compress() and decompress() return data unchanged