Skip to main content

Replay

Struct Replay 

Source
pub struct Replay<'a> { /* private fields */ }
Expand description

順に実行していくもの。DB の実行した高さから始まる

Implementations§

Source§

impl<'a> Replay<'a>

Source

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 のもの)

Source

pub fn set_target(&mut self, target: u64) -> Result<(), ReplayError>

これから実行する目標の高さ(ふつうは確定した高さ)を知らせる。刈り込むなら、目標から残す分を引いたところより 下では差分を書かないようにする。そこまでの差分は消す扱いにする(DB の差分の始まりを上げる)ので、目標は確定した 高さより上にしない。書きかけがあれば、次のコミットのあとで当てる(redb は書く側が1つだけなので)

Source

pub fn store_proof( &mut self, epoch: u32, proof: &[u8], ) -> Result<Option<FinalizedBlockHeader>, ReplayError>

エポック epoch のファイナライズの証明を、実行して求めた投票者で確かめ、指すブロックが実行したものと同じなら しまう。しまった証明は、先端を追う Chain が、確かめた確定として読む。書きかけがあれば先にコミットする。 指すブロックがまだ実行していない高さなら、しまわずに Ok(None) を返す(もっと進めてから呼び直す)

Source

pub fn height(&self) -> u64

実行した高さ(コミットしていない分も含む)

Source

pub fn committed(&self) -> u64

最後にコミットした高さ

Source

pub fn state_hash(&self) -> Option<Hash256>

実行した最後のブロックの StateHash。まだ何も実行していなければ None

Source

pub fn push(&mut self, bytes: Vec<u8>) -> Result<(), ReplayError>

次の高さのブロック bytes を確かめて当てる。コミットするまで DB には残らない。

弾いたら、この Replay は途中まで当たった状態なので捨て、Replay::open で開き直す

Source

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> 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.