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

Path Successors [✨ surprises ✨] #22

Merged
merged 2 commits into from
Jul 3, 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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
/target
**/target
108 changes: 104 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[workspace]

members = ["data-model"]
members = ["data-model", "fuzz"]
resolver = "2"

116 changes: 116 additions & 0 deletions data-model/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion data-model/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ version = "0.1.0"
edition = "2021"

[dependencies]
bytes = "1.4"
arbitrary = { version = "1.0.2", features = ["derive"]}
6 changes: 5 additions & 1 deletion data-model/src/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,11 @@ mod tests {

#[derive(Default, PartialEq, Eq, PartialOrd, Ord, Clone)]
struct FakeSubspaceId(usize);
impl SubspaceId for FakeSubspaceId {}
impl SubspaceId for FakeSubspaceId {
fn successor(&self) -> Option<Self> {
Some(FakeSubspaceId(self.0 + 1))
}
}

#[derive(Default, PartialEq, Eq, PartialOrd, Ord, Clone)]
struct FakePayloadDigest(usize);
Expand Down
8 changes: 6 additions & 2 deletions data-model/src/grouping/area.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::{
path::Path,
};

use super::{range::Range, range_3d::Range3d};
use super::range::Range;

/// The possible values of an [`Area`]'s `subspace`.
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord)]
Expand Down Expand Up @@ -112,7 +112,11 @@ mod tests {

#[derive(Debug, Default, PartialEq, Eq, PartialOrd, Ord, Clone)]
struct FakeSubspaceId(usize);
impl SubspaceId for FakeSubspaceId {}
impl SubspaceId for FakeSubspaceId {
fn successor(&self) -> Option<Self> {
Some(FakeSubspaceId(self.0 + 1))
}
}

#[derive(Default, PartialEq, Eq, PartialOrd, Ord, Clone)]
struct FakePayloadDigest(usize);
Expand Down
6 changes: 5 additions & 1 deletion data-model/src/grouping/range_3d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,11 @@ mod tests {

#[derive(Default, PartialEq, Eq, PartialOrd, Ord, Clone, Debug)]
struct FakeSubspaceId(usize);
impl SubspaceId for FakeSubspaceId {}
impl SubspaceId for FakeSubspaceId {
fn successor(&self) -> Option<Self> {
Some(FakeSubspaceId(self.0 + 1))
}
}

#[derive(Default, PartialEq, Eq, PartialOrd, Ord, Clone)]
struct FakePayloadDigest(usize);
Expand Down
6 changes: 5 additions & 1 deletion data-model/src/parameters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ pub trait NamespaceId: Eq + Default + Clone {}
/// ## Implementation notes
///
/// The [`Default`] implementation **must** return the least element in the total order of [`SubspaceId`].
pub trait SubspaceId: Ord + Default + Clone {}
pub trait SubspaceId: Ord + Default + Clone {
/// Return the next possible value in the set of all [`SubspaceId`].
/// e.g. the successor of 3 is 4.
fn successor(&self) -> Option<Self>;
}

/// A totally ordered type for [content-addressing](https://en.wikipedia.org/wiki/Content_addressing) the data that Willow stores.
/// [Definition](https://willowprotocol.org/specs/data-model/index.html#PayloadDigest).
Expand Down
Loading