[−][src]Struct nakamoto_common::block::time::AdjustedTime
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]
fn clone(&self) -> AdjustedTime<K>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[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,
K: RefUnwindSafe,
impl<K> Send for AdjustedTime<K> where
K: Send,
K: Send,
impl<K> Sync for AdjustedTime<K> where
K: Sync,
K: Sync,
impl<K> Unpin for AdjustedTime<K> where
K: Unpin,
K: Unpin,
impl<K> UnwindSafe for AdjustedTime<K> where
K: UnwindSafe,
K: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,