pub struct Batch { /* private fields */ }Expand description
まとめて書くもの。
Implementations§
Source§impl Batch
impl Batch
Sourcepub fn put_block(&mut self, height: u64, block: &[u8]) -> Result<(), DbError>
pub fn put_block(&mut self, height: u64, block: &[u8]) -> Result<(), DbError>
ブロックを足す。高さの順を守るのは呼ぶ側。
Searches::NAMESPACES なら、ネームスペースの登録から名前の表も足す。Searches::TRANSACTIONS なら、
トランザクションのハッシュとアドレスの表も足し、その高さにあったブロック(枝を取り替えたとき)の分を消す。
エイリアスを解決した先のアドレスは、ステートメントを足すとき(Batch::put_statement)に足す
Sourcepub fn remove_orphan(
&mut self,
height: u64,
hash: &[u8; 32],
) -> Result<(), DbError>
pub fn remove_orphan( &mut self, height: u64, hash: &[u8; 32], ) -> Result<(), DbError>
自分の枝に入れたブロックが孤立ブロックの表にあれば消す(枝が行ったり来たりしたとき)
Sourcepub fn put_statement(
&mut self,
height: u64,
statement: &[u8],
) -> Result<(), DbError>
pub fn put_statement( &mut self, height: u64, statement: &[u8], ) -> Result<(), DbError>
ステートメントを足す。Searches::TRANSACTIONS なら、その高さのブロック(先に Batch::put_block で
足したもの)のトランザクションに、エイリアスを解決した先のアドレスも足す
Sourcepub fn remove_blocks_through(
&mut self,
through: u64,
keep: impl Fn(u64) -> bool,
) -> Result<(), DbError>
pub fn remove_blocks_through( &mut self, through: u64, keep: impl Fn(u64) -> bool, ) -> Result<(), DbError>
through 以下のブロックを、keep が真の高さのほかは消す。追いつく段階で、もう再開に要らないブロックを
書いた端から消すのに使う(ファイルが広がらないよう、空いたページを次の書き込みで使い回す)。
残っている一番低い高さ(Db::blocks_from)は変えない
Sourcepub fn put_checkpoint(
&mut self,
height: u64,
executor: &[u8],
) -> Result<(), DbError>
pub fn put_checkpoint( &mut self, height: u64, executor: &[u8], ) -> Result<(), DbError>
height でコミットする、木に入らない実行の状態
pub fn put_voters(&mut self, epoch: u32, voters: &[u8]) -> Result<(), DbError>
pub fn put_state(&mut self, key: &[u8], value: &[u8]) -> Result<(), DbError>
pub fn delete_state(&mut self, key: &[u8]) -> Result<(), DbError>
Sourcepub fn set_state_at<K: AsRef<[u8]>, V: AsRef<[u8]>>(
&mut self,
height: u64,
writes: impl IntoIterator<Item = (K, Option<V>)>,
) -> Result<(), DbError>
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 に残す。
同じキーは高さの順に書くこと。
Sourcepub fn set_trie_at<K: AsRef<[u8]>, V: AsRef<[u8]>>(
&mut self,
height: u64,
writes: impl IntoIterator<Item = (K, Option<V>)>,
) -> Result<(), DbError>
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 と同じことを、木のノードで。
Sourcepub fn defer_history_after(&mut self, height: u64) -> Result<(), DbError>
pub fn defer_history_after(&mut self, height: u64) -> Result<(), DbError>
history を後回しにするとき、今は height までできていることを残す。もっと前までしかできていなければ、そのまま
Sourcepub fn start_history(&mut self, height: u64) -> Result<(), DbError>
pub fn start_history(&mut self, height: u64) -> Result<(), DbError>
状態の差分を残し始める高さを、まだ決めていなければ決める。
Sourcepub fn start_trie(&mut self, height: u64) -> Result<(), DbError>
pub fn start_trie(&mut self, height: u64) -> Result<(), DbError>
木のノードの差分を残し始める高さを、まだ決めていなければ決める。
pub fn put_meta(&mut self, name: &str, value: &[u8]) -> Result<(), DbError>
Sourcepub fn replace_known_peers(
&mut self,
peers: &[(String, Vec<u8>)],
) -> Result<(), DbError>
pub fn replace_known_peers( &mut self, peers: &[(String, Vec<u8>)], ) -> Result<(), DbError>
住所録を peers で置き換える
Sourcepub fn commit_lazily(self) -> Result<(), DbError>
pub fn commit_lazily(self) -> Result<(), DbError>
まとめて書くが、ディスクに書き出し終わるのを待たない。落ちると、前に Batch::commit したところまで戻る。
Trait Implementations§
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> 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