-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Evolve
BlockStore
trait (#402)
- Use new RPITIT instead of `async_trait` macro for all traits - Expose blanket implementation `impl<B: BlockStore> BlockStore for &B` and `Box<B>` - Add two functions to `trait BlockStore`: - `async fn has_block(&self, cid: &Cid) -> Result<bool>;` to find out whether a block is available locally - `async fn put_block_keyed(&self, cid: &Cid, bytes: impl Into<Bytes> + CondSend) -> Result<()>;` to add a block with given CID to the blockstore. This allows us to support adding blocks using different hashing functions to the same blockstore. - Use explicit `BlockStoreError` type in `trait Blockstore` instead of `anyhow::Error` - Update `rug` dependency to `1.24` --- * feat: Implement `BlockStore` for derefs, too * refactor: Use new RPITIT feature for `trait BlockStore` * refactor: Move `trait PrivateForest` to RPITIT * refactor: Use RPITIT in `trait PrivateKey` & `trait ExchangeKey` * refactor: Completely remove `async_trait` * chore: Fix warnings, remove unused `IpldEq` trait * fix: Update rug & enable std feature * feat: don't require `std` for `rug`, more efficient `to_bytes_be` * chore: Fix nightly warning * refactor: Blanket-impl for `&B` and `Box<B>` instead of `Deref` This way is recommended by dtolnay (rust-lang/api-guidelines#158) and the "Rust for Rustaceans" book (paragraph "Ergonomic Trait Implementations"). This leads to better compiler error messages when you pass something that doesn't `impl BlockStore` the right way. `rand_core` explicitly decided against a `DerefMut` blanket implementation for `trait RngCore`. * refactor: Remove serializable things from `BlockStore` Use the `Storable` trait and its `store` and `load` functions instead. * feat: Add `has_block` to `trait BlockStore` * fix: Update accesskey snapshot * fix: Implement `has_block` for `ForeignBlockStore` * feat: Add `get_block_keyed` to `trait BlockStore`, fix wasm * refactor: Move blockstore interface close to extern * refactor: Use precise error type in `trait BlockStore` * feat: Return correct error in `ForeignBlockStore::get_block` * refactor: Use `libipld_core::serde::to_ipld` instead of dag-cbor * docs: Add comments explaining use of `boxed_fut`
- Loading branch information
Showing
47 changed files
with
410 additions
and
334 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
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
Oops, something went wrong.