mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 05:51:02 +00:00
Chain Selection: Follow-ups (#3328)
* DB skeleton * key formats * lexicographic test * custom types for DB * implement backend for db-v1 * remove VoidBackend and integrate with real DbBackend * detect stagnant blocks on in interval * fix tests * add tests for stagnant * send ChainSelectionMessage::Approved * tests for DB backend * unused import * upgrade kvdb-memorydb Co-authored-by: Andronik Ordian <write@reusable.software>
This commit is contained in:
committed by
GitHub
parent
5ba0de035e
commit
f69c175119
@@ -251,8 +251,9 @@ pub(crate) fn import_block(
|
||||
parent_hash: Hash,
|
||||
reversion_logs: Vec<BlockNumber>,
|
||||
weight: BlockWeight,
|
||||
stagnant_at: Timestamp,
|
||||
) -> Result<(), Error> {
|
||||
add_block(backend, block_hash, block_number, parent_hash, weight)?;
|
||||
add_block(backend, block_hash, block_number, parent_hash, weight, stagnant_at)?;
|
||||
apply_reversions(
|
||||
backend,
|
||||
block_hash,
|
||||
@@ -308,6 +309,7 @@ fn add_block(
|
||||
block_number: BlockNumber,
|
||||
parent_hash: Hash,
|
||||
weight: BlockWeight,
|
||||
stagnant_at: Timestamp,
|
||||
) -> Result<(), Error> {
|
||||
let mut leaves = backend.load_leaves()?;
|
||||
let parent_entry = backend.load_block_entry(&parent_hash)?;
|
||||
@@ -350,7 +352,6 @@ fn add_block(
|
||||
backend.write_blocks_by_number(block_number, blocks_by_number);
|
||||
|
||||
// 5. Add stagnation timeout.
|
||||
let stagnant_at = crate::stagnant_timeout_from_now();
|
||||
let mut stagnant_at_list = backend.load_stagnant_at(stagnant_at)?;
|
||||
stagnant_at_list.push(block_hash);
|
||||
backend.write_stagnant_at(stagnant_at, stagnant_at_list);
|
||||
@@ -549,8 +550,6 @@ pub(super) fn approve_block(
|
||||
///
|
||||
/// This accepts a fresh backend and returns an overlay on top of it representing
|
||||
/// all changes made.
|
||||
// TODO https://github.com/paritytech/polkadot/issues/3293:: remove allow
|
||||
#[allow(unused)]
|
||||
pub(super) fn detect_stagnant<'a, B: 'a + Backend>(
|
||||
backend: &'a B,
|
||||
up_to: Timestamp,
|
||||
|
||||
Reference in New Issue
Block a user