pub struct Chain<'a, S: ChainStore + StateSource> { /* private fields */ }Expand description
チェーンの持ち主
Implementations§
Source§impl<S: ChainStore + StateSource> Chain<'_, S>
impl<S: ChainStore + StateSource> Chain<'_, S>
Sourcepub fn check_partial(
&mut self,
transaction: &Transaction,
) -> Result<Option<PartialCheck>, ChainError>
pub fn check_partial( &mut self, transaction: &Transaction, ) -> Result<Option<PartialCheck>, ChainError>
transaction(連署を付けたもの)を確かめる。ハッシュロックが確定して使えるようになっていなければ None。
要るものだけをメモリに持つ形なら、要る行を読み込んでから見る。マルチシグをたどる途中で読んでいない行に
当たったら、読み足して見直す
Source§impl<'a, S: ChainStore + StateSource> Chain<'a, S>
impl<'a, S: ChainStore + StateSource> Chain<'a, S>
Sourcepub async fn new(
store: &'a S,
env: &'a dyn Env,
config: ChainConfig,
parameters: &'static NetworkParameters,
partial: bool,
) -> Result<Self, ChainError>
pub async fn new( store: &'a S, env: &'a dyn Env, config: ChainConfig, parameters: &'static NetworkParameters, partial: bool, ) -> Result<Self, ChainError>
partial なら、アカウントの表を全部はメモリに持たず、ブロックごとに要る分だけ読む
Sourcepub fn set_harvesters(&mut self, keys: Arc<Vec<(PrivateKey, PrivateKey)>>)
pub fn set_harvesters(&mut self, keys: Arc<Vec<(PrivateKey, PrivateKey)>>)
先端の段階で、keys(署名の鍵、VRF の鍵。リモートならリモートの鍵)でハーベストする
動かしたまま入れ替えてよく、次に先端が変わるのを待たずに、当たりの時刻を求め直す
Sourcepub fn set_pending(&mut self, pending: Arc<dyn Pending>)
pub fn set_pending(&mut self, pending: Arc<dyn Pending>)
ブロックを作るときに、pending から候補をもらう。渡すと、先端の枝に入ったものと外れたものを
Action::Included と Action::Restored で知らせる
Sourcepub fn set_beneficiary(&mut self, beneficiary: Option<Address>)
pub fn set_beneficiary(&mut self, beneficiary: Option<Address>)
作るブロックの受取先(報酬のうち受取先の分を受け取るアドレス)。None なら、署名した鍵のアドレスにする。
委任を引き受けるノードは、運営者のアドレスにする
Sourcepub fn set_assemble(&mut self, assemble: Arc<dyn Assemble>)
pub fn set_assemble(&mut self, assemble: Arc<dyn Assemble>)
ブロックを作るときに、手数料で選んだトランザクションを assemble に渡して直してもらう
Sourcepub fn harvest_plan(&self) -> HarvestPlan
pub fn harvest_plan(&self) -> HarvestPlan
今の先端の上で求めた、ハーベストの当たり。画面に「次の当たり」を出すときに読む
Sourcepub fn harvest_outlook(&self) -> Option<HarvestOutlook>
pub fn harvest_outlook(&self) -> Option<HarvestOutlook>
今の先端の上で求めた、ハーベストの見込み。当たりを求めていないか、直近のブロックが足りなければ None
Sourcepub fn state_matches(&mut self) -> bool
pub fn state_matches(&mut self) -> bool
メモリの状態の根が、先端のブロックの StateHash と合うか
Sourcepub async fn extend_offline(
&mut self,
block: &Block,
bytes: Vec<u8>,
) -> Result<(), ChainError>
pub async fn extend_offline( &mut self, block: &Block, bytes: Vec<u8>, ) -> Result<(), ChainError>
ピアなしで、先端の次のブロック block を確かめて当て、コミットする(調べもの用)。知らせは指示に積む
Sourcepub async fn switch_offline(
&mut self,
common: u64,
blocks: Vec<(Block, Vec<u8>)>,
) -> Result<bool, ChainError>
pub async fn switch_offline( &mut self, common: u64, blocks: Vec<(Block, Vec<u8>)>, ) -> Result<bool, ChainError>
分かれ目 common から先を、ピアなしで枝 blocks に取り替えてみる(switch-check)。取り替えたら真、
通らないかスコアが高くなくて元の枝に戻したら偽
Sourcepub fn anchor(&self) -> FinalizedBlockHeader
pub fn anchor(&self) -> FinalizedBlockHeader
確かめた確定のうち、自分の枝の上にあるとわかっている一番新しいもの。ここより下は分かれていない
Sourcepub async fn rewind_to(&mut self, common: u64) -> Result<(), ChainError>
pub async fn rewind_to(&mut self, common: u64) -> Result<(), ChainError>
先端を、Self::anchor 以上の高さ common まで、ピアなしで巻き戻す。外れる枝は孤立ブロックの表に残す。
追いつく段階の前に、実行した先端がピアのチェーンから外れていたときに使う(追いつく段階は先端の続きを
取るだけで、分かれ目を探さない)
Sourcepub fn take_actions(&mut self) -> Vec<Action>
pub fn take_actions(&mut self) -> Vec<Action>
駆動役にまだ渡していない指示を受け取る
Sourcepub async fn handle(
&mut self,
event: ChainEvent,
) -> Result<Option<Outcome>, ChainError>
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> 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
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