[][src]Struct nakamoto_common::block::time::AdjustedTime

pub struct AdjustedTime<K> { /* fields omitted */ }

Network-adjusted time tracker.

Network-adjusted time is the median timestamp of all connected peers. Since we store only time offsets for each peer, the network-adjusted time is the local time plus the median offset of all connected peers.

Nb. Network time is never adjusted more than 70 minutes from local system time.

Implementations

impl<K: Hash + Eq> AdjustedTime<K>[src]

pub fn new(local_time: LocalTime) -> Self[src]

Create a new network-adjusted time tracker. Starts with a single sample of zero.

pub fn record_offset(&mut self, source: K, sample: TimeOffset)[src]

Add a time sample to influence the network-adjusted time.

pub fn offset(&self) -> TimeOffset[src]

Get the median network time offset.

pub fn from(&self, time: Time) -> Time[src]

Get the network-adjusted time given a local time.

pub fn get(&self) -> Time[src]

Get the current network-adjusted time.

pub fn set_local_time(&mut self, time: LocalTime)[src]

Set the local time to the given value.

pub fn local_time(&self) -> LocalTime[src]

Get the last known local time.

Trait Implementations

impl<K: Eq + Hash> Clock for AdjustedTime<K>[src]

impl<K: Clone> Clone for AdjustedTime<K>[src]

impl<K: Debug> Debug for AdjustedTime<K>[src]

impl<K: Hash + Eq> Default for AdjustedTime<K>[src]

Auto Trait Implementations

impl<K> RefUnwindSafe for AdjustedTime<K> where
    K: RefUnwindSafe

impl<K> Send for AdjustedTime<K> where
    K: Send

impl<K> Sync for AdjustedTime<K> where
    K: Sync

impl<K> Unpin for AdjustedTime<K> where
    K: Unpin

impl<K> UnwindSafe for AdjustedTime<K> where
    K: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.