Skip to main content

Batch

Struct Batch 

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

まとめて書くもの。

Implementations§

Source§

impl Batch

Source

pub fn put_block(&mut self, height: u64, block: &[u8]) -> Result<(), DbError>

ブロックを足す。高さの順を守るのは呼ぶ側。 Searches::NAMESPACES なら、ネームスペースの登録から名前の表も足す。Searches::TRANSACTIONS なら、 トランザクションのハッシュとアドレスの表も足し、その高さにあったブロック(枝を取り替えたとき)の分を消す。 エイリアスを解決した先のアドレスは、ステートメントを足すとき(Batch::put_statement)に足す

Source

pub fn put_proof(&mut self, epoch: u32, proof: &[u8]) -> Result<(), DbError>

ファイナライズの証明を足す。

Source

pub fn remove_orphan( &mut self, height: u64, hash: &[u8; 32], ) -> Result<(), DbError>

自分の枝に入れたブロックが孤立ブロックの表にあれば消す(枝が行ったり来たりしたとき)

Source

pub fn put_statement( &mut self, height: u64, statement: &[u8], ) -> Result<(), DbError>

ステートメントを足す。Searches::TRANSACTIONS なら、その高さのブロック(先に Batch::put_block で 足したもの)のトランザクションに、エイリアスを解決した先のアドレスも足す

Source

pub fn remove_blocks_through( &mut self, through: u64, keep: impl Fn(u64) -> bool, ) -> Result<(), DbError>

through 以下のブロックを、keep が真の高さのほかは消す。追いつく段階で、もう再開に要らないブロックを 書いた端から消すのに使う(ファイルが広がらないよう、空いたページを次の書き込みで使い回す)。 残っている一番低い高さ(Db::blocks_from)は変えない

Source

pub fn put_checkpoint( &mut self, height: u64, executor: &[u8], ) -> Result<(), DbError>

height でコミットする、木に入らない実行の状態

Source

pub fn put_voters(&mut self, epoch: u32, voters: &[u8]) -> Result<(), DbError>

Source

pub fn put_state(&mut self, key: &[u8], value: &[u8]) -> Result<(), DbError>

Source

pub fn delete_state(&mut self, key: &[u8]) -> Result<(), DbError>

Source

pub fn set_state_at<K: AsRef<[u8]>, V: AsRef<[u8]>>( &mut self, height: u64, writes: impl IntoIterator<Item = (K, Option<V>)>, ) -> Result<(), DbError>

height のブロックで、状態の行をキーごとに値にする(None なら消す)。 前と違えば、変わる前の値を changesets に、高さを history に残す。 同じキーは高さの順に書くこと。

Source

pub fn set_trie_at<K: AsRef<[u8]>, V: AsRef<[u8]>>( &mut self, height: u64, writes: impl IntoIterator<Item = (K, Option<V>)>, ) -> Result<(), DbError>

Batch::set_state_at と同じことを、木のノードで。

Source

pub fn defer_history_after(&mut self, height: u64) -> Result<(), DbError>

history を後回しにするとき、今は height までできていることを残す。もっと前までしかできていなければ、そのまま

Source

pub fn start_history(&mut self, height: u64) -> Result<(), DbError>

状態の差分を残し始める高さを、まだ決めていなければ決める。

Source

pub fn start_trie(&mut self, height: u64) -> Result<(), DbError>

木のノードの差分を残し始める高さを、まだ決めていなければ決める。

Source

pub fn put_meta(&mut self, name: &str, value: &[u8]) -> Result<(), DbError>

Source

pub fn replace_known_peers( &mut self, peers: &[(String, Vec<u8>)], ) -> Result<(), DbError>

住所録を peers で置き換える

Source

pub fn commit(self) -> Result<(), DbError>

まとめてディスクに残す。

Source

pub fn commit_lazily(self) -> Result<(), DbError>

まとめて書くが、ディスクに書き出し終わるのを待たない。落ちると、前に Batch::commit したところまで戻る。

Trait Implementations§

Source§

impl StateSource for Batch

書きかけの中から読む。まだコミットしていない、この書きかけで書いたものも見える。何ブロックかをまとめてコミットしながら、 状態を全部はメモリに持たずに実行するとき(replay::Replay)の読み口

Source§

fn row(&self, key: &[u8]) -> Result<Option<Vec<u8>>, ExecError>

状態の行 key(super::persist::row_key)。なければ None
Source§

fn node(&self, key: &[u8]) -> Result<Option<Vec<u8>>, ExecError>

木のノード key(crate::tree::node_key)。なければ None
Source§

fn for_each_row( &self, prefix: &[u8], visit: &mut dyn FnMut(&[u8], &[u8]), ) -> Result<(), ExecError>

キーが prefix で始まる状態の行を、キーの順に visit に渡す。全部を一度にメモリに置かない

Auto Trait Implementations§

§

impl !Freeze for Batch

§

impl !RefUnwindSafe for Batch

§

impl !UnwindSafe for Batch

§

impl Send for Batch

§

impl Sync for Batch

§

impl Unpin for Batch

§

impl UnsafeUnpin for Batch

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.