pub struct Replay<'a> { /* private fields */ }Expand description
順に実行していくもの。DB の実行した高さから始まる
Implementations§
Source§impl<'a> Replay<'a>
impl<'a> Replay<'a>
Sourcepub fn open(
db: &'a Db,
config: ChainConfig,
parameters: &'static NetworkParameters,
nemesis: Hash256,
keep: Option<Keep>,
partial: bool,
) -> Result<Self, ReplayError>
pub fn open( db: &'a Db, config: ChainConfig, parameters: &'static NetworkParameters, nemesis: Hash256, keep: Option<Keep>, partial: bool, ) -> Result<Self, ReplayError>
db の、最後にコミットした高さから続ける。空の DB なら、次は Nemesis(ハッシュが nemesis のもの)
Sourcepub fn set_target(&mut self, target: u64) -> Result<(), ReplayError>
pub fn set_target(&mut self, target: u64) -> Result<(), ReplayError>
これから実行する目標の高さ(ふつうは確定した高さ)を知らせる。刈り込むなら、目標から残す分を引いたところより 下では差分を書かないようにする。そこまでの差分は消す扱いにする(DB の差分の始まりを上げる)ので、目標は確定した 高さより上にしない。書きかけがあれば、次のコミットのあとで当てる(redb は書く側が1つだけなので)
Sourcepub fn store_proof(
&mut self,
epoch: u32,
proof: &[u8],
) -> Result<Option<FinalizedBlockHeader>, ReplayError>
pub fn store_proof( &mut self, epoch: u32, proof: &[u8], ) -> Result<Option<FinalizedBlockHeader>, ReplayError>
エポック epoch のファイナライズの証明を、実行して求めた投票者で確かめ、指すブロックが実行したものと同じなら
しまう。しまった証明は、先端を追う Chain が、確かめた確定として読む。書きかけがあれば先にコミットする。
指すブロックがまだ実行していない高さなら、しまわずに Ok(None) を返す(もっと進めてから呼び直す)
Sourcepub fn state_hash(&self) -> Option<Hash256>
pub fn state_hash(&self) -> Option<Hash256>
実行した最後のブロックの StateHash。まだ何も実行していなければ None
Sourcepub fn push(&mut self, bytes: Vec<u8>) -> Result<(), ReplayError>
pub fn push(&mut self, bytes: Vec<u8>) -> Result<(), ReplayError>
次の高さのブロック bytes を確かめて当てる。コミットするまで DB には残らない。
弾いたら、この Replay は途中まで当たった状態なので捨て、Replay::open で開き直す
Sourcepub fn commit(&mut self) -> Result<(), ReplayError>
pub fn commit(&mut self) -> Result<(), ReplayError>
ここまで当てたものを書く。書き終えたら、次に開いたときはここから続く
Auto Trait Implementations§
impl<'a> !Freeze for Replay<'a>
impl<'a> !RefUnwindSafe for Replay<'a>
impl<'a> !UnwindSafe for Replay<'a>
impl<'a> Send for Replay<'a>
impl<'a> Sync for Replay<'a>
impl<'a> Unpin for Replay<'a>
impl<'a> UnsafeUnpin for Replay<'a>
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
Mutably borrows from an owned value. Read more
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> ⓘ
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 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> ⓘ
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