Skip to main content

RoundContext

Struct RoundContext 

Source
pub struct RoundContext { /* private fields */ }
Expand description

1つのラウンドの投票の数え方。catapult の RoundContext

Implementations§

Source§

impl RoundContext

Source

pub fn new(total_weight: u64, threshold: u64) -> Self

投票者の重みの合計が total_weight、閾値が threshold のラウンド

Source

pub fn len(&self) -> usize

prevote のあったブロックの数

Source

pub fn is_empty(&self) -> bool

Source

pub fn weights(&self, candidate: Candidate) -> Weights

ブロックに集まった重み。prevote のないブロックは 0

Source

pub fn best_prevote(&self) -> Option<Candidate>

prevote が閾値に届いた、いちばん高いブロック

Source

pub fn best_precommit(&self) -> Option<Candidate>

prevote と precommit の両方が閾値に届いた、いちばん高いブロック

Source

pub fn estimate(&self) -> Option<Candidate>

best prevote とその祖先のうち、precommit がまだ閾値に届きうる、いちばん高いブロック

Source

pub fn is_descendant(&self, parent: Candidate, child: Candidate) -> bool

child が parent 自身か、その子孫か。どちらかに prevote がなければ偽

Source

pub fn is_completable(&self) -> bool

ラウンドの結果がもう変わらないか。catapult の isCompletable

Source

pub fn accept_prevote(&mut self, height: u64, hashes: &[Hash256], weight: u64)

高さ height から続くブロック hashes への prevote を、重み weight で数える

Source

pub fn accept_precommit(&mut self, height: u64, hash: Hash256, weight: u64)

ブロック(height、hash)への precommit を、重み weight で数える。prevote がまだなければ取っておく

Trait Implementations§

Source§

impl Debug for RoundContext

Source§

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

Formats the value using the given formatter. Read more

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> 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> Same for T

Source§

type Output = T

Should always be Self
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.