pub struct ContinuityProof {
pub origin_hash: u64,
pub from_seq: u64,
pub to_seq: u64,
pub from_hash: u64,
pub to_hash: u64,
}Expand description
Compact proof of continuity that can be transmitted (40 bytes).
A node can send this to another node to prove its chain is intact over a given sequence range, without transferring the full log.
Fields§
§origin_hash: u64Entity origin hash.
from_seq: u64Start of the proven range.
to_seq: u64End of the proven range.
from_hash: u64parent_hash computed from the event at from_seq.
to_hash: u64parent_hash computed from the event at to_seq.
Implementations§
Source§impl ContinuityProof
impl ContinuityProof
Sourcepub fn from_log(log: &EntityLog) -> Option<Self>
pub fn from_log(log: &EntityLog) -> Option<Self>
Extract a proof from a local entity log.
Returns None if the log is empty.
Sourcepub fn verify_against(&self, log: &EntityLog) -> Result<(), ProofError>
pub fn verify_against(&self, log: &EntityLog) -> Result<(), ProofError>
Verify this proof against a local entity log.
Walks the entire event range [from_seq, to_seq],
re-computing each parent_hash and asserting it matches
the chain link emitted by the previous event. The endpoint
hashes (from_hash / to_hash) are also verified against
the local log.
Rejects reversed bounds, caps the span at
MAX_PROOF_VERIFY_SPAN, walks every event in range, and
validates each consecutive parent_hash link. Checking
only the two endpoint events would let a malicious
intermediary holding events 0 and 999 ship a proof spanning
[0, 999] with the correct two endpoint hashes that
verify_against would accept — even though events 1..998
could be missing or fabricated, defeating the whole point
of the proof. The span cap also prevents a peer from
forcing a multi-billion-event scan via reversed or wide
bounds.
Sourcepub fn from_bytes(data: &[u8]) -> Option<Self>
pub fn from_bytes(data: &[u8]) -> Option<Self>
Deserialize from bytes.
Rejects buffers whose length differs from
CONTINUITY_PROOF_SIZE so trailing bytes aren’t silently
accepted (the old < SIZE guard let concatenated proofs or
framing garbage parse as the first proof).
Trait Implementations§
Source§impl Clone for ContinuityProof
impl Clone for ContinuityProof
Source§fn clone(&self) -> ContinuityProof
fn clone(&self) -> ContinuityProof
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for ContinuityProof
Source§impl Debug for ContinuityProof
impl Debug for ContinuityProof
impl Eq for ContinuityProof
Source§impl PartialEq for ContinuityProof
impl PartialEq for ContinuityProof
Source§fn eq(&self, other: &ContinuityProof) -> bool
fn eq(&self, other: &ContinuityProof) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for ContinuityProof
Auto Trait Implementations§
impl Freeze for ContinuityProof
impl RefUnwindSafe for ContinuityProof
impl Send for ContinuityProof
impl Sync for ContinuityProof
impl Unpin for ContinuityProof
impl UnsafeUnpin for ContinuityProof
impl UnwindSafe for ContinuityProof
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,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.