pub struct EncodedPostBundleV1 {
pub header: EncodedPostBundleHeaderV1,
pub encoded_posts_bytes: Bytes,
}Fields§
§header: EncodedPostBundleHeaderV1§encoded_posts_bytes: BytesImplementations§
Source§impl EncodedPostBundleV1
impl EncodedPostBundleV1
pub fn to_bytes(&self) -> Result<Bytes>
pub fn from_bytes(bytes: Bytes, decode_body: bool) -> Result<Self>
Sourcepub fn verify(&self, base_id: &Id) -> Result<()>
pub fn verify(&self, base_id: &Id) -> Result<()>
Verifies that this bundle is legitimate enough to cache.
Checks:
- The bundle header is structurally valid and its signature verifies.
- The sum of
encoded_post_lengthsexactly spansencoded_posts_bytes, and the plaintextpost_idprefix of each slice matches the corresponding entry inencoded_post_ids. - Each post slice can be decrypted using
base_id, which also verifies the per-post signature and hash integrity.
Sourcepub fn verify_for_bucket(
&self,
bucket_location: &BucketLocation,
time_millis_now: TimeMillis,
) -> Result<()>
pub fn verify_for_bucket( &self, bucket_location: &BucketLocation, time_millis_now: TimeMillis, ) -> Result<()>
Verifies that this bundle is a legitimate bundle for bucket_location, as received from the network.
On top of EncodedPostBundleV1::verify:
- The publishing peer is a genuine server identity (server-id PoW, id derived from its key, self-signed).
EncodedPostBundleHeaderV1::verifyalone only checks the header against the key the header itself supplies. - The bundle is for this bucket’s location_id.
- No post appears twice.
- The header timestamp is plausible: not before the bucket starts and not in the future (both allowing for clock drift).
- Every post could legitimately have been admitted into this bucket - see
EncodedPostV1::check_admissible_to_bucket.
An empty bundle can pass: whether an empty bundle is acceptable is up to the caller.
The sealed / overflowed flags are not checked here - see EncodedPostBundleV1::normalise_flags_for_bucket.
Sourcepub fn normalise_flags_for_bucket(
&mut self,
bucket_location: &BucketLocation,
time_millis_now: TimeMillis,
)
pub fn normalise_flags_for_bucket( &mut self, bucket_location: &BucketLocation, time_millis_now: TimeMillis, )
Replaces the publisher-asserted overflowed / sealed flags with values the receiver can stand behind:
- a bundle holding more posts than the overflow threshold is overflowed, whatever it says,
sealedis recomputed from the bucket and the (already bounds-checked) header timestamp, as the server would have.
This deliberately normalises rather than rejects: the posts in such a bundle are still genuine, and older servers
can legitimately produce inconsistent flags (e.g. by healing posts in without recomputing them).
The header timestamp is clamped to time_millis_now: verify_for_bucket tolerates it being up to a clock drift in our future,
which must not let a publisher seal its bundle (and so pin it in caches with no expiry) before the bucket has really sealed.
NB: the header signature no longer covers the flags after this, so only use the result locally - never forward it.
Trait Implementations§
Source§impl Clone for EncodedPostBundleV1
impl Clone for EncodedPostBundleV1
Source§fn clone(&self) -> EncodedPostBundleV1
fn clone(&self) -> EncodedPostBundleV1
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for EncodedPostBundleV1
impl Debug for EncodedPostBundleV1
Source§impl Display for EncodedPostBundleV1
impl Display for EncodedPostBundleV1
Source§impl PartialEq for EncodedPostBundleV1
impl PartialEq for EncodedPostBundleV1
Source§fn eq(&self, other: &EncodedPostBundleV1) -> bool
fn eq(&self, other: &EncodedPostBundleV1) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for EncodedPostBundleV1
Auto Trait Implementations§
impl !Freeze for EncodedPostBundleV1
impl RefUnwindSafe for EncodedPostBundleV1
impl Send for EncodedPostBundleV1
impl Sync for EncodedPostBundleV1
impl Unpin for EncodedPostBundleV1
impl UnsafeUnpin for EncodedPostBundleV1
impl UnwindSafe for EncodedPostBundleV1
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more