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

Store trait #21

Merged
merged 45 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
fd2007c
Sketch of Store trait
sgwilym Aug 20, 2024
54968da
ok
sgwilym Jun 26, 2024
b7ad9b0
good comments
sgwilym Jun 27, 2024
f2b490d
wip who cares
sgwilym Aug 20, 2024
c6bb42e
Begin rework: ingest_entry, append_bytes, LengthyEntry
sgwilym Aug 20, 2024
0885197
Make ingest / append async, add TODO on bulk entry ingestion
sgwilym Aug 20, 2024
f999e19
Store.forgetEntry
sgwilym Aug 20, 2024
fe8702c
Add forgetting by area methods
sgwilym Aug 20, 2024
a23e76d
Add payload forgetting methods
sgwilym Aug 20, 2024
f01dcff
Add flush
sgwilym Aug 20, 2024
38ecd75
Add bulk_ingest_entry, Store::FlushError
sgwilym Aug 21, 2024
98a9b73
prevent_pruning param, revisit bulk ingestion result
sgwilym Aug 21, 2024
fe7b7b1
Better docs for bulk ingestion
sgwilym Aug 21, 2024
f4f72bc
add entry method
sgwilym Aug 21, 2024
9305aca
Add query_area method
sgwilym Aug 22, 2024
bbf09c0
Add subscription fns
sgwilym Aug 22, 2024
f1cf5e1
fix Store.resume_subscription params
sgwilym Aug 22, 2024
3483478
Add into_entry, AsRef impls for LengthEntry
sgwilym Aug 26, 2024
108d765
Refactor how pruned entries are reported
sgwilym Aug 26, 2024
851b8c9
Store.entry should return future
sgwilym Aug 26, 2024
c6bdc09
NoSuchEntryError does not need parentheses
sgwilym Aug 26, 2024
5079c76
Use impl return types for producers instead of associated type
sgwilym Aug 26, 2024
9161dcb
Update data-model/src/store.rs
sgwilym Aug 26, 2024
e780240
Add Store::OperationsError associated type
sgwilym Aug 26, 2024
aec0d59
Add forget_payload_unchecked
sgwilym Aug 26, 2024
288fe8c
Improve producer param name
sgwilym Aug 26, 2024
89d7d19
Different return type for forget_entry
sgwilym Aug 26, 2024
9277add
no references to deleting
sgwilym Aug 26, 2024
32c9318
Update data-model/src/store.rs
sgwilym Aug 26, 2024
a130c47
Update data-model/src/store.rs
sgwilym Aug 26, 2024
09b7016
Clarify “payload too long” error
sgwilym Aug 27, 2024
cc2a67e
Single forget_area fn with protected param
sgwilym Aug 27, 2024
e133097
Add missing &self param / make many params references
sgwilym Aug 27, 2024
f824d43
Add QueryIgnoreParams
sgwilym Aug 27, 2024
4f3fcd4
Update QueryOrder
sgwilym Aug 27, 2024
a578229
Update data-model/src/store.rs
sgwilym Aug 27, 2024
74e6202
Merge store into store-trait-query
sgwilym Aug 27, 2024
ade83c7
Merge pull request #48 from earthstar-project/store-trait-query
sgwilym Aug 27, 2024
4c6cfc7
Rename forget_payload_unchecked
sgwilym Aug 28, 2024
b8a87ad
Make payload forgetting APIs more consistent
sgwilym Aug 28, 2024
b8de760
Add EntryOrigin to ingestion
sgwilym Aug 29, 2024
de0f72f
Use Areas for subscriptions
sgwilym Aug 29, 2024
d39f7e0
Add standard derives
sgwilym Aug 29, 2024
51ab2c4
tedious implementation of Error
sgwilym Aug 29, 2024
914bc63
clearer docs for EntryOrigin
sgwilym Aug 30, 2024
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
122 changes: 122 additions & 0 deletions data-model/src/lengthy_entry.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
use crate::{AuthorisationToken, AuthorisedEntry, Entry, NamespaceId, PayloadDigest, SubspaceId};

/// An [`Entry`] together with information about how much of its payload a given [`Store`] holds.
///
/// [Definition](https://willowprotocol.org/specs/3d-range-based-set-reconciliation/index.html#LengthyEntry)
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct LengthyEntry<const MCL: usize, const MCC: usize, const MPL: usize, N, S, PD>
where
N: NamespaceId,
S: SubspaceId,
PD: PayloadDigest,
{
/// The Entry in question.
entry: Entry<MCL, MCC, MPL, N, S, PD>,
/// The number of consecutive bytes from the start of the entry’s payload that the peer holds.
available: u64,
}

impl<const MCL: usize, const MCC: usize, const MPL: usize, N, S, PD>
LengthyEntry<MCL, MCC, MPL, N, S, PD>
where
N: NamespaceId,
S: SubspaceId,
PD: PayloadDigest,
{
/// Create a new lengthy entry from a given [`Entry`] and the number of consecutive bytes from the start of the entry’s payload that are held.
pub fn new(entry: Entry<MCL, MCC, MPL, N, S, PD>, available: u64) -> Self {
Self { entry, available }
}

/// The entry in question.
pub fn entry(&self) -> &Entry<MCL, MCC, MPL, N, S, PD> {
&self.entry
}

/// The number of consecutive bytes from the start of the entry’s Payload that the peer holds.
pub fn available(&self) -> u64 {
self.available
}

/// Turn this into a regular [`Entry`].
pub fn into_entry(self) -> Entry<MCL, MCC, MPL, N, S, PD> {
self.entry
}
}

impl<const MCL: usize, const MCC: usize, const MPL: usize, N, S, PD>
AsRef<Entry<MCL, MCC, MPL, N, S, PD>> for LengthyEntry<MCL, MCC, MPL, N, S, PD>
where
N: NamespaceId,
S: SubspaceId,
PD: PayloadDigest,
{
fn as_ref(&self) -> &Entry<MCL, MCC, MPL, N, S, PD> {
&self.entry
}
}

/// An [`AuthorisedEntry`] together with information about how much of its payload a given [`Store`] holds.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct LengthyAuthorisedEntry<
const MCL: usize,
const MCC: usize,
const MPL: usize,
N,
S,
PD,
AT,
> where
N: NamespaceId,
S: SubspaceId,
PD: PayloadDigest,
AT: AuthorisationToken<MCL, MCC, MPL, N, S, PD>,
{
/// The Entry in question.
entry: AuthorisedEntry<MCL, MCC, MPL, N, S, PD, AT>,
/// The number of consecutive bytes from the start of the entry’s payload that the peer holds.
available: u64,
}

impl<const MCL: usize, const MCC: usize, const MPL: usize, N, S, PD, AT>
LengthyAuthorisedEntry<MCL, MCC, MPL, N, S, PD, AT>
where
N: NamespaceId,
S: SubspaceId,
PD: PayloadDigest,
AT: AuthorisationToken<MCL, MCC, MPL, N, S, PD>,
{
/// Create a new lengthy entry from a given [`AuthorisedEntry`] and the number of consecutive bytes from the start of the entry’s payload that are held.
pub fn new(entry: AuthorisedEntry<MCL, MCC, MPL, N, S, PD, AT>, available: u64) -> Self {
Self { entry, available }
}

/// The entry in question.
pub fn entry(&self) -> &AuthorisedEntry<MCL, MCC, MPL, N, S, PD, AT> {
&self.entry
}

/// The number of consecutive bytes from the start of the entry’s Payload that the peer holds.
pub fn available(&self) -> u64 {
self.available
}

/// Turn this into a [`AuthorisedEntry`].
pub fn into_authorised_entry(self) -> AuthorisedEntry<MCL, MCC, MPL, N, S, PD, AT> {
self.entry
}
}

impl<const MCL: usize, const MCC: usize, const MPL: usize, N, S, PD, AT>
AsRef<AuthorisedEntry<MCL, MCC, MPL, N, S, PD, AT>>
for LengthyAuthorisedEntry<MCL, MCC, MPL, N, S, PD, AT>
where
N: NamespaceId,
S: SubspaceId,
PD: PayloadDigest,
AT: AuthorisationToken<MCL, MCC, MPL, N, S, PD>,
{
fn as_ref(&self) -> &AuthorisedEntry<MCL, MCC, MPL, N, S, PD, AT> {
&self.entry
}
}
4 changes: 4 additions & 0 deletions data-model/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,13 @@

mod entry;
pub use entry::*;
mod lengthy_entry;
pub use lengthy_entry::*;
pub mod grouping;
mod parameters;
pub use parameters::*;
mod path;
pub use path::*;
mod relative_encodings;
mod store;
pub use store::*;
Loading
Loading