pub struct ParentDeclaration { /* private fields */ }Expand description
A node’s declaration of its parent in the spanning tree.
Each node periodically announces its parent selection. The declaration
includes a monotonic sequence number for freshness and a signature
for authenticity. When parent_id == node_addr, the node declares itself
as a root candidate.
Implementations§
Source§impl ParentDeclaration
impl ParentDeclaration
Sourcepub fn new(
node_addr: NodeAddr,
parent_id: NodeAddr,
sequence: u64,
timestamp: u64,
) -> Self
pub fn new( node_addr: NodeAddr, parent_id: NodeAddr, sequence: u64, timestamp: u64, ) -> Self
Create a new unsigned parent declaration.
The declaration must be signed before transmission using set_signature().
Sourcepub fn self_root(node_addr: NodeAddr, sequence: u64, timestamp: u64) -> Self
pub fn self_root(node_addr: NodeAddr, sequence: u64, timestamp: u64) -> Self
Create a self-declaration (node is root candidate).
Sourcepub fn with_signature(
node_addr: NodeAddr,
parent_id: NodeAddr,
sequence: u64,
timestamp: u64,
signature: Signature,
) -> Self
pub fn with_signature( node_addr: NodeAddr, parent_id: NodeAddr, sequence: u64, timestamp: u64, signature: Signature, ) -> Self
Create a declaration with a pre-computed signature.
Sourcepub fn set_signature(&mut self, signature: Signature)
pub fn set_signature(&mut self, signature: Signature)
Set the signature after signing.
Sourcepub fn sign(&mut self, identity: &Identity) -> Result<(), TreeError>
pub fn sign(&mut self, identity: &Identity) -> Result<(), TreeError>
Sign this declaration with the given identity.
The identity’s node_addr must match this declaration’s node_addr. Returns an error if the node_addrs don’t match.
Sourcepub fn signing_bytes(&self) -> Vec<u8> ⓘ
pub fn signing_bytes(&self) -> Vec<u8> ⓘ
Get the bytes that should be signed.
Format: node_addr (16) || parent_id (16) || sequence (8) || timestamp (8)
Sourcepub fn verify(&self, pubkey: &XOnlyPublicKey) -> Result<(), TreeError>
pub fn verify(&self, pubkey: &XOnlyPublicKey) -> Result<(), TreeError>
Verify the signature on this declaration.
Returns Ok(()) if the signature is valid, or an error otherwise.
Sourcepub fn is_fresher_than(&self, other: &ParentDeclaration) -> bool
pub fn is_fresher_than(&self, other: &ParentDeclaration) -> bool
Check if this declaration is fresher than another.
Trait Implementations§
Source§impl Clone for ParentDeclaration
impl Clone for ParentDeclaration
Source§fn clone(&self) -> ParentDeclaration
fn clone(&self) -> ParentDeclaration
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 ParentDeclaration
impl Debug for ParentDeclaration
Source§impl PartialEq for ParentDeclaration
impl PartialEq for ParentDeclaration
impl Eq for ParentDeclaration
Auto Trait Implementations§
impl Freeze for ParentDeclaration
impl RefUnwindSafe for ParentDeclaration
impl Send for ParentDeclaration
impl Sync for ParentDeclaration
impl Unpin for ParentDeclaration
impl UnsafeUnpin for ParentDeclaration
impl UnwindSafe for ParentDeclaration
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.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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