-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Have VM trait expose a dyn blockstore (#1328)
* wip * refactor VM trait to return a dyn Blockstore * refactor miner_withdrawal_tests to not need BS: Blockstore * VM trait should use abstract primitives (#1329)
- Loading branch information
Showing
23 changed files
with
439 additions
and
381 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
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
use cid::Cid; | ||
use fvm_ipld_blockstore::Blockstore; | ||
|
||
/// A DynBlockstore is used to make the blockstore trait object consumable by functions that | ||
/// accept a generic BS: Blockstore parameter rather than a dyn Blockstore | ||
pub struct DynBlockstore<'bs>(&'bs dyn Blockstore); | ||
|
||
impl<'bs> Blockstore for DynBlockstore<'bs> { | ||
fn get(&self, k: &Cid) -> anyhow::Result<Option<Vec<u8>>> { | ||
self.0.get(k) | ||
} | ||
|
||
fn put_keyed(&self, k: &Cid, block: &[u8]) -> anyhow::Result<()> { | ||
self.0.put_keyed(k, block) | ||
} | ||
} | ||
|
||
impl<'bs> DynBlockstore<'bs> { | ||
pub fn wrap(blockstore: &'bs dyn Blockstore) -> Self { | ||
Self(blockstore) | ||
} | ||
} |
Oops, something went wrong.