0g-storage-node/node/miner/src/loader.rs

21 lines
580 B
Rust
Raw Normal View History

2024-01-03 10:24:52 +00:00
use async_trait::async_trait;
use std::sync::Arc;
use storage::log_store::{MineLoadChunk, Store};
use tokio::sync::RwLock;
#[async_trait]
pub trait PoraLoader: Send + Sync {
async fn load_sealed_data(&self, index: u64) -> Option<MineLoadChunk>;
}
#[async_trait]
impl PoraLoader for Arc<RwLock<dyn Store>> {
async fn load_sealed_data(&self, chunk_index: u64) -> Option<MineLoadChunk> {
let store = &*self.read().await;
match store.flow().load_sealed_data(chunk_index) {
Ok(Some(chunk)) => Some(chunk),
_ => None,
}
}
}