pub struct HFVotes { /* private fields */ }Expand description
A struct holding the current voting state of the blockchain.
Implementations§
Source§impl HFVotes
impl HFVotes
pub fn new(window_size: usize) -> Self
Sourcepub fn add_vote_for_hf(&mut self, hf: &HardFork)
pub fn add_vote_for_hf(&mut self, hf: &HardFork)
Add a vote for a hard-fork, this function removes votes outside of the window.
Sourcepub fn reverse_blocks(&mut self, numb_blocks: usize, old_block_votes: Self)
pub fn reverse_blocks(&mut self, numb_blocks: usize, old_block_votes: Self)
Pop a number of blocks from the top of the cache and push some values into the front of the cache, i.e. the oldest blocks.
old_block_votes should contain the HFs below the window that now will be in the window after popping
blocks from the top.
§Panics
This will panic if old_block_votes contains more HFs than numb_blocks.
Sourcepub fn votes_for_hf(&self, hf: &HardFork) -> usize
pub fn votes_for_hf(&self, hf: &HardFork) -> usize
Returns the total votes for a hard-fork.
ref: https://monero-book.cuprate.org/consensus_rules/hardforks.html#accepting-a-fork
Sourcepub fn total_votes(&self) -> usize
pub fn total_votes(&self) -> usize
Returns the total amount of votes being tracked
Sourcepub fn current_fork(
&self,
current_hf: &HardFork,
current_height: usize,
window: usize,
hfs_info: &HFsInfo,
) -> HardFork
pub fn current_fork( &self, current_hf: &HardFork, current_height: usize, window: usize, hfs_info: &HFsInfo, ) -> HardFork
Checks if a future hard fork should be activated, returning the next hard-fork that should be activated.
ref: https://monero-book.cuprate.org/consensus_rules/hardforks.html#accepting-a-fork
Trait Implementations§
impl Eq for HFVotes
impl StructuralPartialEq for HFVotes
Auto Trait Implementations§
impl Freeze for HFVotes
impl RefUnwindSafe for HFVotes
impl Send for HFVotes
impl Sync for HFVotes
impl Unpin for HFVotes
impl UnsafeUnpin for HFVotes
impl UnwindSafe for HFVotes
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘwhere
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘwhere
S: Into<Dispatch>,
§fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ
fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 168 bytes