pub struct EncodedPostBundleFeedbackV1 {
pub header: EncodedPostBundleFeedbackHeaderV1,
pub feedbacks_bytes: Bytes,
}Fields§
§header: EncodedPostBundleFeedbackHeaderV1§feedbacks_bytes: BytesImplementations§
Source§impl EncodedPostBundleFeedbackV1
impl EncodedPostBundleFeedbackV1
pub fn to_bytes(&self) -> Result<Bytes>
pub fn from_bytes(bytes: Bytes) -> Result<Self>
Sourcepub fn verify(&self) -> Result<()>
pub fn verify(&self) -> Result<()>
Verifies that this bundle is legitimate enough to cache.
Checks:
- The bundle header is valid and its signature verifies.
- The feedback body is a valid multiple of
ENTRY_SIZE(no partial entries). - The header’s hash is the same as the body’s
- Each feedback entry’s proof-of-work is correct.
Sourcepub fn verify_for_location(&self, location_id: &Id) -> Result<()>
pub fn verify_for_location(&self, location_id: &Id) -> Result<()>
Verifies that this bundle is a legitimate feedback bundle for location_id, as received from the network.
On top of EncodedPostBundleFeedbackV1::verify:
- The publishing peer is a genuine server identity (server-id PoW, id derived from its key, self-signed).
EncodedPostBundleFeedbackHeaderV1::verifyalone only checks the header against the key the header itself supplies. - The bundle is for this location_id.
Sourcepub fn verify_origin_for_location(&self, location_id: &Id) -> Result<()>
pub fn verify_origin_for_location(&self, location_id: &Id) -> Result<()>
Self::verify_for_location minus the per-entry PoW check: proves a genuine server published this bundle for location_id,
but tolerates individual entries with bad PoW, which Self::merge drops one at a time. For a server’s own (direct) copy, so that
one bad entry it holds cannot erase all of its other feedback. Never forward a bundle that has only passed this check.
pub fn get_post_pow_for_feedback_type( &self, post_id: &Id, feedback_type: u8, ) -> Pow
Sourcepub fn merge(bundles: &[Self]) -> Option<Self>
pub fn merge(bundles: &[Self]) -> Option<Self>
Unions an array of bundles by taking the highest-pow entry for each
(post_id, feedback_type) pair across all bundles. The header is
taken from the most-recently-timestamped bundle. Returns None if
bundles is empty.
Entries whose claimed pow does not match what their salt achieves are dropped individually. The bundle header signature only proves which server produced the bundle, not that its entries are honest, so a dishonest (or poisoned) server must not be able to plant pow=255 flags. Dropping per-entry rather than rejecting the whole bundle means one bad entry cannot erase all other feedback for the bucket.
pub fn get_post_pows(&self, post_id: &Id) -> [Pow; 256]
Trait Implementations§
Source§impl Clone for EncodedPostBundleFeedbackV1
impl Clone for EncodedPostBundleFeedbackV1
Source§fn clone(&self) -> EncodedPostBundleFeedbackV1
fn clone(&self) -> EncodedPostBundleFeedbackV1
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 EncodedPostBundleFeedbackV1
impl Debug for EncodedPostBundleFeedbackV1
Source§impl PartialEq for EncodedPostBundleFeedbackV1
impl PartialEq for EncodedPostBundleFeedbackV1
Source§fn eq(&self, other: &EncodedPostBundleFeedbackV1) -> bool
fn eq(&self, other: &EncodedPostBundleFeedbackV1) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for EncodedPostBundleFeedbackV1
Auto Trait Implementations§
impl !Freeze for EncodedPostBundleFeedbackV1
impl RefUnwindSafe for EncodedPostBundleFeedbackV1
impl Send for EncodedPostBundleFeedbackV1
impl Sync for EncodedPostBundleFeedbackV1
impl Unpin for EncodedPostBundleFeedbackV1
impl UnsafeUnpin for EncodedPostBundleFeedbackV1
impl UnwindSafe for EncodedPostBundleFeedbackV1
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