Struct grin_chain::types::Tip

source ·
pub struct Tip {
    pub height: u64,
    pub last_block_h: Hash,
    pub prev_block_h: Hash,
    pub total_difficulty: Difficulty,
}
Expand description

The tip of a fork. A handle to the fork ancestry from its leaf in the blockchain tree. References the max height and the latest and previous blocks for convenience and the total difficulty.

Fields§

§height: u64

Height of the tip (max height of the fork)

§last_block_h: Hash

Last block pushed to the fork

§prev_block_h: Hash

Previous block

§total_difficulty: Difficulty

Total difficulty accumulated on that fork

Implementations§

source§

impl Tip

source

pub fn from_header(header: &BlockHeader) -> Tip

Creates a new tip based on provided header.

Trait Implementations§

source§

impl Clone for Tip

source§

fn clone(&self) -> Tip

Returns a copy 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 Tip

source§

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

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

impl Default for Tip

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<'de> Deserialize<'de> for Tip

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl From<&BlockHeader> for Tip

source§

fn from(header: &BlockHeader) -> Self

Converts to this type from the input type.
source§

impl From<BlockHeader> for Tip

source§

fn from(header: BlockHeader) -> Self

Converts to this type from the input type.
source§

impl Hashed for Tip

source§

fn hash(&self) -> Hash

The hash of the underlying block.

source§

impl PartialEq for Tip

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Readable for Tip

source§

fn read<R: Reader>(reader: &mut R) -> Result<Tip, Error>

Reads the data necessary to this Readable from the provided reader
source§

impl Serialize for Tip

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Writeable for Tip

Serialization of a tip, required to save to datastore.

source§

fn write<W: Writer>(&self, writer: &mut W) -> Result<(), Error>

Write the data held by this Writeable to the provided writer
source§

impl Copy for Tip

source§

impl StructuralPartialEq for Tip

Auto Trait Implementations§

§

impl Freeze for Tip

§

impl RefUnwindSafe for Tip

§

impl Send for Tip

§

impl Sync for Tip

§

impl Unpin for Tip

§

impl UnwindSafe for Tip

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> CloneAny for T
where T: Any + Clone,

source§

fn clone_any(&self) -> Box<dyn CloneAny>

source§

fn clone_any_send(&self) -> Box<dyn CloneAny + Send>
where T: Send,

source§

fn clone_any_sync(&self) -> Box<dyn CloneAny + Sync>
where T: Sync,

source§

fn clone_any_send_sync(&self) -> Box<dyn CloneAny + Send + Sync>
where T: Send + Sync,

source§

impl<'a, T> DefaultFeatures<'a> for T
where T: 'a + Send + Sync + Clone,

source§

fn clone_boxed(&self) -> Box<dyn DefaultFeatures<'a>>

Clone this value, and then immediately put it into a Box behind a trait object of this trait.
source§

fn self_address_mut(&mut self) -> *mut ()

Returns the address of self. 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<'a, T> NonSyncFeatures<'a> for T
where T: 'a + Clone,

source§

fn clone_boxed(&self) -> Box<dyn NonSyncFeatures<'a>>

Clone this value, and then immediately put it into a Box behind a trait object of this trait.
source§

fn self_address_mut(&mut self) -> *mut ()

Returns the address of self. Read more
source§

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

source§

fn borrow_replacement(ptr: &T) -> &T

Given ptr, which was obtained from a prior call to Self::borrow(), return a value with the same nominal lifetime which is guaranteed to survive mutations to Self. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<H> ShortIdentifiable for H
where H: Hashed,

source§

fn short_id(&self, hash: &Hash, nonce: u64) -> ShortId

Generate a short_id via the following -

  • extract k0/k1 from block_hash hashed with the nonce (first two u64 values) * initialize a siphasher24 with k0/k1
    • self.hash() passing in the siphasher24 instance
    • drop the 2 most significant bytes (to return a 6 byte short_id)
source§

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

§

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>,

§

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>,

§

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> DebugAny for T
where T: Any + Debug,

source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

source§

impl<T> UnsafeAny for T
where T: Any,