mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 19:11:04 +00:00
update kvdb & co (#6111)
* toml changes * REVERTME: patch * adapt parachains db interface * fix Cargo.toml patch after master rebase * fix av-store * fix chain-selection * fix parachains-db? * Revert "fix Cargo.toml patch after master rebase" This reverts commit 3afcbf033c86027b3f2b909d83ec703591bdd287. * Revert "REVERTME: patch" This reverts commit 464b717cf4142d3d09c3d77b83700b632d8c5f54. * Use `Ok` imported from prelude Co-authored-by: Bastian Köcher <info@kchr.de> * update lockfile for {"substrate"} * Revert "update lockfile for {"substrate"}" This reverts commit fdc623de226f7645741b86c4b1a7d030fed2172d. * cargo update -p sp-io Co-authored-by: Bastian Köcher <info@kchr.de> Co-authored-by: parity-processbot <>
This commit is contained in:
@@ -792,8 +792,9 @@ fn note_block_included(
|
||||
macro_rules! peek_num {
|
||||
($iter:ident) => {
|
||||
match $iter.peek() {
|
||||
Some((k, _)) => decode_unfinalized_key(&k[..]).ok().map(|(b, _, _)| b),
|
||||
None => None,
|
||||
Some(Ok((k, _))) => Ok(decode_unfinalized_key(&k[..]).ok().map(|(b, _, _)| b)),
|
||||
Some(Err(_)) => Err($iter.next().expect("peek returned Some(Err); qed").unwrap_err()),
|
||||
None => Ok(None),
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -819,10 +820,10 @@ async fn process_block_finalized<Context>(
|
||||
let mut iter = subsystem
|
||||
.db
|
||||
.iter_with_prefix(subsystem.config.col_meta, &start_prefix)
|
||||
.take_while(|(k, _)| &k[..] < &end_prefix[..])
|
||||
.take_while(|r| r.as_ref().map_or(true, |(k, _v)| &k[..] < &end_prefix[..]))
|
||||
.peekable();
|
||||
|
||||
match peek_num!(iter) {
|
||||
match peek_num!(iter)? {
|
||||
None => break, // end of iterator.
|
||||
Some(n) => n,
|
||||
}
|
||||
@@ -867,10 +868,10 @@ async fn process_block_finalized<Context>(
|
||||
let iter = subsystem
|
||||
.db
|
||||
.iter_with_prefix(subsystem.config.col_meta, &start_prefix)
|
||||
.take_while(|(k, _)| &k[..] < &end_prefix[..])
|
||||
.take_while(|r| r.as_ref().map_or(true, |(k, _v)| &k[..] < &end_prefix[..]))
|
||||
.peekable();
|
||||
|
||||
let batch = load_all_at_finalized_height(iter, batch_num, batch_finalized_hash);
|
||||
let batch = load_all_at_finalized_height(iter, batch_num, batch_finalized_hash)?;
|
||||
|
||||
// Now that we've iterated over the entire batch at this finalized height,
|
||||
// update the meta.
|
||||
@@ -890,22 +891,22 @@ async fn process_block_finalized<Context>(
|
||||
// loads all candidates at the finalized height and maps them to `true` if finalized
|
||||
// and `false` if unfinalized.
|
||||
fn load_all_at_finalized_height(
|
||||
mut iter: std::iter::Peekable<impl Iterator<Item = (Box<[u8]>, Box<[u8]>)>>,
|
||||
mut iter: std::iter::Peekable<impl Iterator<Item = io::Result<util::database::DBKeyValue>>>,
|
||||
block_number: BlockNumber,
|
||||
finalized_hash: Hash,
|
||||
) -> impl IntoIterator<Item = (CandidateHash, bool)> {
|
||||
) -> io::Result<impl IntoIterator<Item = (CandidateHash, bool)>> {
|
||||
// maps candidate hashes to true if finalized, false otherwise.
|
||||
let mut candidates = HashMap::new();
|
||||
|
||||
// Load all candidates that were included at this height.
|
||||
loop {
|
||||
match peek_num!(iter) {
|
||||
match peek_num!(iter)? {
|
||||
None => break, // end of iterator.
|
||||
Some(n) if n != block_number => break, // end of batch.
|
||||
_ => {},
|
||||
}
|
||||
|
||||
let (k, _v) = iter.next().expect("`peek` used to check non-empty; qed");
|
||||
let (k, _v) = iter.next().expect("`peek` used to check non-empty; qed")?;
|
||||
let (_, block_hash, candidate_hash) =
|
||||
decode_unfinalized_key(&k[..]).expect("`peek_num` checks validity of key; qed");
|
||||
|
||||
@@ -916,7 +917,7 @@ fn load_all_at_finalized_height(
|
||||
}
|
||||
}
|
||||
|
||||
candidates
|
||||
Ok(candidates)
|
||||
}
|
||||
|
||||
fn update_blocks_at_finalized_height(
|
||||
@@ -1214,9 +1215,10 @@ fn prune_all(db: &Arc<dyn Database>, config: &Config, clock: &dyn Clock) -> Resu
|
||||
let mut tx = DBTransaction::new();
|
||||
let iter = db
|
||||
.iter_with_prefix(config.col_meta, &range_start[..])
|
||||
.take_while(|(k, _)| &k[..] < &range_end[..]);
|
||||
.take_while(|r| r.as_ref().map_or(true, |(k, _v)| &k[..] < &range_end[..]));
|
||||
|
||||
for (k, _v) in iter {
|
||||
for r in iter {
|
||||
let (k, _v) = r?;
|
||||
tx.delete(config.col_meta, &k[..]);
|
||||
|
||||
let (_, candidate_hash) = match decode_pruning_key(&k[..]) {
|
||||
|
||||
Reference in New Issue
Block a user