-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
finishing up with save and get block
- Loading branch information
1 parent
ac707b2
commit c86c6fb
Showing
4 changed files
with
85 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,21 @@ | ||
use solana_lite_rpc_core::traits::block_storage_interface::BlockStorageInterface; | ||
use anyhow::bail; | ||
use solana_lite_rpc_core::{ | ||
traits::block_storage_interface::BlockStorageInterface, types::BlockStream, AnyhowJoinHandle, | ||
}; | ||
use std::sync::Arc; | ||
|
||
pub struct History { | ||
pub block_storage: Arc<dyn BlockStorageInterface>, | ||
} | ||
|
||
impl History { | ||
pub fn start_saving_blocks(&self, mut block_notifier: BlockStream) -> AnyhowJoinHandle { | ||
let block_storage = self.block_storage.clone(); | ||
tokio::spawn(async move { | ||
while let Ok(block) = block_notifier.recv().await { | ||
block_storage.save(block).await?; | ||
} | ||
bail!("saving of blocks stopped"); | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters