Skip to content
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: add unified recon block store implementation #245

Merged
merged 2 commits into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
444 changes: 108 additions & 336 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ members = [
"core",
"event",
"kubo-rpc",
"kubo-rpc-server",
"metadata",
"metrics",
"kubo-rpc-server",
"one",
"p2p",
"recon",
"store",
"beetle/iroh-bitswap",
"beetle/iroh-car",
"beetle/iroh-rpc-client",
Expand Down Expand Up @@ -54,6 +55,7 @@ ceramic-metadata = { path = "./metadata" }
ceramic-metrics = { path = "./metrics" }
ceramic-one = { path = "./one" }
ceramic-p2p = { path = "./p2p" }
ceramic-store = { path = "./store" }
cid = { version = "0.10", features = ["serde-codec"] }
clap = { version = "4", features = ["derive", "env"] }
clap_mangen = "0.2.2"
Expand Down
2 changes: 0 additions & 2 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ license.workspace = true
repository.workspace = true
publish = false

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
anyhow.workspace = true
async-trait.workspace = true
Expand Down
18 changes: 16 additions & 2 deletions core/src/event_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ pub struct WithEvent {
impl BuilderState for WithEvent {}

impl Builder<Init> {
/// Specify the network of the event
pub fn with_network(self, network: &Network) -> Builder<WithNetwork> {
// Maximum EventId size is 72.
//
Expand All @@ -350,8 +351,9 @@ impl Builder<Init> {
}
}
impl Builder<WithNetwork> {
// TODO sort_value should be bytes not str
/// Specify the sort key and value of the event
pub fn with_sort_value(mut self, sort_key: &str, sort_value: &str) -> Builder<WithSortValue> {
// TODO sort_value should be bytes not str
self.state.bytes.extend(last8_bytes(&sha256_digest(&format!(
"{}|{}",
sort_key, sort_value,
Expand All @@ -364,6 +366,7 @@ impl Builder<WithNetwork> {
}
}
impl Builder<WithSortValue> {
/// Specify that the minimum controller value should be used for the event
pub fn with_min_controller(mut self) -> Builder<WithController> {
self.state.bytes.extend(ZEROS_8);
Builder {
Expand All @@ -372,6 +375,7 @@ impl Builder<WithSortValue> {
},
}
}
/// Specify that the maximum controller value should be used for the event
pub fn with_max_controller(mut self) -> Builder<WithController> {
self.state.bytes.extend(FFS_8);
Builder {
Expand All @@ -380,6 +384,7 @@ impl Builder<WithSortValue> {
},
}
}
/// Specify the controller for the event
pub fn with_controller(mut self, controller: &str) -> Builder<WithController> {
self.state
.bytes
Expand All @@ -392,6 +397,7 @@ impl Builder<WithSortValue> {
}
}
impl Builder<WithController> {
/// Specify that the minimum init value should be used for the event
pub fn with_min_init(mut self) -> Builder<WithInit> {
self.state.bytes.extend(ZEROS_4);
Builder {
Expand All @@ -400,6 +406,7 @@ impl Builder<WithController> {
},
}
}
/// Specify that the maximum init value should be used for the event
pub fn with_max_init(mut self) -> Builder<WithInit> {
self.state.bytes.extend(FFS_4);
Builder {
Expand All @@ -408,6 +415,7 @@ impl Builder<WithController> {
},
}
}
/// Specify the init cid of the event
pub fn with_init(mut self, init: &Cid) -> Builder<WithInit> {
self.state
.bytes
Expand All @@ -420,6 +428,7 @@ impl Builder<WithController> {
}
}
impl Builder<WithInit> {
/// Specify that the minimum event height should be used for the event
pub fn with_min_event_height(mut self) -> Builder<WithEventHeight> {
// 0x00 is the cbor encoding of 0.
self.state.bytes.push(0x00);
Expand All @@ -429,6 +438,7 @@ impl Builder<WithInit> {
},
}
}
/// Specify that the maximum event height should be used for the event
pub fn with_max_event_height(mut self) -> Builder<WithEventHeight> {
// 0xFF is the break stop code in CBOR, and will sort higher than any cbor encoded unsigned
// integer.
Expand All @@ -439,6 +449,7 @@ impl Builder<WithInit> {
},
}
}
/// Specify event height for the event
pub fn with_event_height(mut self, event_height: u64) -> Builder<WithEventHeight> {
let event_height_cbor = minicbor::to_vec(event_height).unwrap();
// event_height cbor unsigned int
Expand All @@ -451,10 +462,13 @@ impl Builder<WithInit> {
}
}
impl Builder<WithEventHeight> {
/// Builds the final EventId as a fencepost
/// Builds the final EventId as a fencepost.
/// A fencepost is a value that sorts before and after specific events but is itself not a
/// complete EventId.
pub fn build_fencepost(self) -> EventId {
EventId(self.state.bytes)
}
/// Specify the event cid
pub fn with_event(mut self, event: &Cid) -> Builder<WithEvent> {
self.state.bytes.extend(event.to_bytes());
Builder {
Expand Down
2 changes: 1 addition & 1 deletion core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//! Core functionality for ceramic, including the StreamId, Cid, and Jws types.
#![warn(missing_docs)]
mod bytes;
mod event_id;
pub mod event_id;
mod interest;
mod jwk;
mod jws;
Expand Down
5 changes: 1 addition & 4 deletions kubo-rpc-server/.openapi-generator/FILES
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,8 @@
Cargo.toml
README.md
api/openapi.yaml
docs/BlockPutPost200Response.md
docs/BlockStatPost200Response.md
docs/Codecs.md
docs/DagImportPost200Response.md
docs/DagPutPost200Response.md
docs/DagPutPost200ResponseCid.md
docs/DagResolvePost200Response.md
docs/DagResolvePost200ResponseCid.md
docs/Error.md
Expand Down
6 changes: 0 additions & 6 deletions kubo-rpc-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,9 @@ edition = "2018"
[features]
default = ["client", "server"]
client = [
"mime_0_2",
"multipart", "multipart/client", "swagger/multipart_form",
"hyper", "hyper-openssl", "hyper-tls", "native-tls", "openssl", "url"
]
server = [
"mime_0_2",
"multipart", "multipart/server",
"serde_ignored", "hyper", "regex", "percent-encoding", "url", "lazy_static"
]

Expand All @@ -42,8 +38,6 @@ serde_json = "1.0"
validator = { version = "0.16", features = ["derive"] }

# Crates included if required by the API definition
mime_0_2 = { package = "mime", version = "0.2.6", optional = true }
multipart = { version = "0.16", default-features = false, optional = true }

# Common between server and client features
hyper = {version = "0.14", features = ["full"], optional = true}
Expand Down
13 changes: 2 additions & 11 deletions kubo-rpc-server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ To see how to make this your own, look here:
[README]((https://openapi-generator.tech))

- API version: 0.9.0
- Build date: 2024-01-24T14:39:45.959361295-07:00[America/Denver]
- Build date: 2024-01-26T13:55:46.024253330-07:00[America/Denver]



Expand Down Expand Up @@ -63,11 +63,8 @@ To run a client, follow one of the following simple steps:

```
cargo run --example client BlockGetPost
cargo run --example client BlockPutPost
cargo run --example client BlockStatPost
cargo run --example client DagGetPost
cargo run --example client DagImportPost
cargo run --example client DagPutPost
cargo run --example client DagResolvePost
cargo run --example client IdPost
cargo run --example client PinAddPost
Expand Down Expand Up @@ -109,11 +106,8 @@ All URIs are relative to */api/v0*
Method | HTTP request | Description
------------- | ------------- | -------------
[****](docs/default_api.md#) | **POST** /block/get | Get a single IPFS block
[****](docs/default_api.md#) | **POST** /block/put | Put a single IPFS block
[****](docs/default_api.md#) | **POST** /block/stat | Report statistics about a block
[****](docs/default_api.md#) | **POST** /dag/get | Get an IPLD node from IPFS
[****](docs/default_api.md#) | **POST** /dag/import | Import a CAR file of IPLD nodes into IPFS
[****](docs/default_api.md#) | **POST** /dag/put | Put an IPLD node into IPFS
[****](docs/default_api.md#) | **POST** /dag/resolve | Resolve an IPFS path to a DAG node
[****](docs/default_api.md#) | **POST** /id | Report identifying information about a node
[****](docs/default_api.md#) | **POST** /pin/add | Add a block to the pin store
Expand All @@ -125,11 +119,8 @@ Method | HTTP request | Description

## Documentation For Models

- [BlockPutPost200Response](docs/BlockPutPost200Response.md)
- [BlockStatPost200Response](docs/BlockStatPost200Response.md)
- [Codecs](docs/Codecs.md)
- [DagImportPost200Response](docs/DagImportPost200Response.md)
- [DagPutPost200Response](docs/DagPutPost200Response.md)
- [DagPutPost200ResponseCid](docs/DagPutPost200ResponseCid.md)
- [DagResolvePost200Response](docs/DagResolvePost200Response.md)
- [DagResolvePost200ResponseCid](docs/DagResolvePost200ResponseCid.md)
- [Error](docs/Error.md)
Expand Down
Loading
Loading