-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(): index storage scaffolding & rocksdb implementation #47
Merged
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
f71b85c
feat: piecestore
cernicc 97c362f
feat: wip piecestore
cernicc 6688baa
fix: rename rocks store
cernicc 6056d3b
fix: change interface & move to separate folder
cernicc 7b20661
feat: implemented add_deal_for_piece
cernicc 6d0d90b
feat: refactor to use column families
cernicc 07f3a12
feat: some aditional types and rocksdb impl
cernicc f3af7db
fix: small changes
cernicc 08180f9
chore: use workspace dependencies
cernicc 4c10711
Merge branch 'develop' into feat/41/index_storage_scaffolding
serg-temchenko ceb4a33
feat: impl ciborium
cernicc 0b0a073
feat: add tests
cernicc 4f8c0e5
build: fix taplo
cernicc 4d80107
fix: change error
cernicc bb2d427
fix: fmt
cernicc f860151
fix: pr related changes
cernicc 6a7198f
Merge branch 'develop' into feat/41/index_storage_scaffolding
serg-temchenko 2c158f0
fix: add additional comment
cernicc 067c2cc
feat: move piecestore to polka-index
cernicc c068e40
fix: taplo
cernicc 75e7807
fix: comment
cernicc a9498ab
fix: pr related changes
cernicc ab4a730
fix: docs
cernicc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,3 +19,6 @@ target/ | |
|
||
# reproducible local environment | ||
.direnv | ||
|
||
# Visual Studio Code | ||
.vscode/ |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Empty file.
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,21 @@ | ||
[package] | ||
authors.workspace = true | ||
edition.workspace = true | ||
homepage.workspace = true | ||
license-file.workspace = true | ||
name = "polka-index" | ||
repository.workspace = true | ||
version = "0.1.0" | ||
|
||
[dependencies] | ||
ciborium = { workspace = true } | ||
cid = { workspace = true, features = ["serde"] } | ||
rocksdb = { workspace = true } | ||
serde = { workspace = true } | ||
thiserror = { workspace = true } | ||
|
||
[dev-dependencies] | ||
tempfile = { workspace = true } | ||
|
||
[lints] | ||
workspace = true |
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 @@ | ||
pub mod piecestore; |
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,3 @@ | ||
fn main() { | ||
println!("Hello, world!"); | ||
} |
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,4 @@ | ||
# piecestore | ||
|
||
The piecestore module is a simple encapsulation of two data stores, one for `PieceInfo` and | ||
another for `CidInfo`. |
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,69 @@ | ||
use std::collections::HashMap; | ||
|
||
use cid::Cid; | ||
use rocksdb::RocksDBError; | ||
use thiserror::Error; | ||
|
||
use self::types::{BlockLocation, CidInfo, DealInfo, PieceInfo}; | ||
|
||
pub mod rocksdb; | ||
pub mod types; | ||
|
||
pub trait PieceStore { | ||
th7nder marked this conversation as resolved.
Show resolved
Hide resolved
|
||
/// Implementation-specific configuration. | ||
type Config; | ||
|
||
/// Initialize a new store. | ||
fn new(config: Self::Config) -> Result<Self, PieceStoreError> | ||
where | ||
Self: Sized; | ||
|
||
/// Store [`DealInfo`] in the PieceStore with key piece [`Cid`]. | ||
fn add_deal_for_piece( | ||
&self, | ||
piece_cid: &Cid, | ||
deal_info: DealInfo, | ||
) -> Result<(), PieceStoreError>; | ||
|
||
/// Store the map of [`BlockLocation`] in the [`PieceStore`]'s [`CidInfo`] store, with | ||
/// key piece [`Cid`]. | ||
/// | ||
/// Note: If a piece block location is already present in the [`CidInfo`], it | ||
/// will be ignored. | ||
fn add_piece_block_locations( | ||
&self, | ||
piece_cid: &Cid, | ||
block_locations: &HashMap<Cid, BlockLocation>, | ||
) -> Result<(), PieceStoreError>; | ||
|
||
/// List all piece [`Cid`]s stored in the [`PieceStore`]. | ||
fn list_piece_info_keys(&self) -> Result<Vec<Cid>, PieceStoreError>; | ||
|
||
/// List all [`CidInfo`]s keys stored in the [`PieceStore`]. | ||
fn list_cid_info_keys(&self) -> Result<Vec<Cid>, PieceStoreError>; | ||
|
||
/// Retrieve the [`PieceInfo`] for a given piece [`Cid`]. | ||
fn get_piece_info(&self, cid: &Cid) -> Result<Option<PieceInfo>, PieceStoreError>; | ||
|
||
/// Retrieve the [`CidInfo`] associated with piece [`Cid`]. | ||
fn get_cid_info(&self, cid: &Cid) -> Result<Option<CidInfo>, PieceStoreError>; | ||
} | ||
|
||
/// Error that can occur when interacting with the [`PieceStore`]. | ||
#[derive(Debug, Error)] | ||
pub enum PieceStoreError { | ||
#[error("Initialization error: {0}")] | ||
Initialization(String), | ||
|
||
#[error("Deal already exists")] | ||
DealExists, | ||
|
||
#[error("Serialization error: {0}")] | ||
Serialization(String), | ||
|
||
#[error("Deserialization error: {0}")] | ||
Deserialization(String), | ||
|
||
#[error(transparent)] | ||
StoreError(#[from] RocksDBError), | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we please add the crate level doc with text from the readme?