Skip to main content

Chain

Struct Chain 

Source
pub struct Chain<'a, S: ChainStore + StateSource> { /* private fields */ }
Expand description

チェーンの持ち主

Implementations§

Source§

impl<S: ChainStore + StateSource> Chain<'_, S>

Source

pub fn check_partial( &mut self, transaction: &Transaction, ) -> Result<Option<PartialCheck>, ChainError>

transaction(連署を付けたもの)を確かめる。ハッシュロックが確定して使えるようになっていなければ None。 要るものだけをメモリに持つ形なら、要る行を読み込んでから見る。マルチシグをたどる途中で読んでいない行に 当たったら、読み足して見直す

Source§

impl<'a, S: ChainStore + StateSource> Chain<'a, S>

Source

pub async fn new( store: &'a S, env: &'a dyn Env, config: ChainConfig, parameters: &'static NetworkParameters, partial: bool, ) -> Result<Self, ChainError>

partial なら、アカウントの表を全部はメモリに持たず、ブロックごとに要る分だけ読む

Source

pub fn set_harvesters(&mut self, keys: Arc<Vec<(PrivateKey, PrivateKey)>>)

先端の段階で、keys(署名の鍵、VRF の鍵。リモートならリモートの鍵)でハーベストする 動かしたまま入れ替えてよく、次に先端が変わるのを待たずに、当たりの時刻を求め直す

Source

pub fn set_pending(&mut self, pending: Arc<dyn Pending>)

ブロックを作るときに、pending から候補をもらう。渡すと、先端の枝に入ったものと外れたものを Action::Included と Action::Restored で知らせる

Source

pub fn set_beneficiary(&mut self, beneficiary: Option<Address>)

作るブロックの受取先(報酬のうち受取先の分を受け取るアドレス)。None なら、署名した鍵のアドレスにする。 委任を引き受けるノードは、運営者のアドレスにする

Source

pub fn set_assemble(&mut self, assemble: Arc<dyn Assemble>)

ブロックを作るときに、手数料で選んだトランザクションを assemble に渡して直してもらう

Source

pub fn set_keep(&mut self, keep: Keep)

確定を上げるたびに、残す分より下の差分を消す

Source

pub fn height(&self) -> u64

実行した高さ

Source

pub fn tip(&self) -> Tip

実行した先端

Source

pub fn harvest_plan(&self) -> HarvestPlan

今の先端の上で求めた、ハーベストの当たり。画面に「次の当たり」を出すときに読む

Source

pub fn harvest_outlook(&self) -> Option<HarvestOutlook>

今の先端の上で求めた、ハーベストの見込み。当たりを求めていないか、直近のブロックが足りなければ None

Source

pub fn status(&self) -> Status

接続してきたピアに答えるときの様子

Source

pub fn state_matches(&mut self) -> bool

メモリの状態の根が、先端のブロックの StateHash と合うか

Source

pub async fn extend_offline( &mut self, block: &Block, bytes: Vec<u8>, ) -> Result<(), ChainError>

ピアなしで、先端の次のブロック block を確かめて当て、コミットする(調べもの用)。知らせは指示に積む

Source

pub async fn switch_offline( &mut self, common: u64, blocks: Vec<(Block, Vec<u8>)>, ) -> Result<bool, ChainError>

分かれ目 common から先を、ピアなしで枝 blocks に取り替えてみる(switch-check)。取り替えたら真、 通らないかスコアが高くなくて元の枝に戻したら偽

Source

pub fn anchor(&self) -> FinalizedBlockHeader

確かめた確定のうち、自分の枝の上にあるとわかっている一番新しいもの。ここより下は分かれていない

Source

pub async fn rewind_to(&mut self, common: u64) -> Result<(), ChainError>

先端を、Self::anchor 以上の高さ common まで、ピアなしで巻き戻す。外れる枝は孤立ブロックの表に残す。 追いつく段階の前に、実行した先端がピアのチェーンから外れていたときに使う(追いつく段階は先端の続きを 取るだけで、分かれ目を探さない)

Source

pub fn add_peer(&mut self, id: PeerId)

ピア id とやりとりを始めたことを知らせる。ほかのノードに教えるために、名乗りを聞く

Source

pub fn take_actions(&mut self) -> Vec<Action>

駆動役にまだ渡していない指示を受け取る

Source

pub async fn handle( &mut self, event: ChainEvent, ) -> Result<Option<Outcome>, ChainError>

出来事を1つ受け取って進める。先端の段階を終えるなら、そのわけを返す。指示は Chain::take_actions で受け取る

Auto Trait Implementations§

§

impl<'a, S> !Freeze for Chain<'a, S>

§

impl<'a, S> !RefUnwindSafe for Chain<'a, S>

§

impl<'a, S> !Send for Chain<'a, S>

§

impl<'a, S> !Sync for Chain<'a, S>

§

impl<'a, S> !UnwindSafe for Chain<'a, S>

§

impl<'a, S> Unpin for Chain<'a, S>

§

impl<'a, S> UnsafeUnpin for Chain<'a, S>

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

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.