Struct NodeAnnouncement

Source
pub struct NodeAnnouncement {
    pub version: u8,
    pub features: Features,
    pub timestamp: Timestamp,
    pub alias: Alias,
    pub addresses: BoundedVec<Address, ADDRESS_LIMIT>,
    pub nonce: u64,
    pub agent: UserAgent,
}
Expand description

Node announcing itself to the network.

Fields§

§version: u8

Supported protocol version.

§features: Features

Advertized features.

§timestamp: Timestamp

Monotonic timestamp.

§alias: Alias

Non-unique alias.

§addresses: BoundedVec<Address, ADDRESS_LIMIT>

Announced addresses.

§nonce: u64

Nonce used for announcement proof-of-work.

§agent: UserAgent

User-agent string.

Implementations§

Source§

impl NodeAnnouncement

Source

pub fn work(&self) -> u32

Calculate the amount of work that went into creating this announcement.

Proof-of-work uses the scrypt algorithm with the parameters in Announcement::POW_PARAMS. The “work” is calculated by counting the number of leading zero bits after running scrypt on a serialized NodeAnnouncement using wire::serialize.

In other words, work = leading-zeros(scrypt(serialize(announcement))).

Higher numbers mean higher difficulty. For each increase in work, difficulty is doubled. For instance, an output of 7 is four times more work than an output of 5.

Source

pub fn solve(self, target: u32) -> Option<Self>

Solve the proof-of-work of a node announcement for the given target, by iterating through different nonces.

If the given difficulty target is too high, there may not be a result. In that case, None is returned.

Trait Implementations§

Source§

impl BindableWithIndex for &NodeAnnouncement

Source§

fn bind<I: ParameterIndex>(self, stmt: &mut Statement<'_>, i: I) -> Result<()>

Bind to a parameter. Read more
Source§

impl Clone for NodeAnnouncement

Source§

fn clone(&self) -> NodeAnnouncement

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for NodeAnnouncement

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Decode for NodeAnnouncement

Source§

fn decode(buf: &mut impl Buf) -> Result<Self, Error>

Source§

impl Encode for NodeAnnouncement

Source§

fn encode(&self, buf: &mut impl BufMut)

Source§

impl From<NodeAnnouncement> for AnnouncementMessage

Source§

fn from(ann: NodeAnnouncement) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for NodeAnnouncement

Source§

fn eq(&self, other: &NodeAnnouncement) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl TryFrom<&Value> for NodeAnnouncement

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: &Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl Eq for NodeAnnouncement

Source§

impl StructuralPartialEq for NodeAnnouncement

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> ErasedDestructor for T
where T: 'static,