mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 21:41:12 +00:00
This reverts commit 172359adad.
This commit is contained in:
@@ -894,12 +894,6 @@ impl<Block: BlockT<Hash=H256>> Backend<Block> {
|
||||
inmem
|
||||
}
|
||||
|
||||
/// Returns total numbet of blocks (headers) in the block DB.
|
||||
#[cfg(feature = "test-helpers")]
|
||||
pub fn blocks_count(&self) -> u64 {
|
||||
self.blockchain.db.iter(columns::HEADER).count() as u64
|
||||
}
|
||||
|
||||
/// Read (from storage or cache) changes trie config.
|
||||
///
|
||||
/// Currently changes tries configuration is set up once (at genesis) and could not
|
||||
@@ -1121,7 +1115,7 @@ impl<Block: BlockT<Hash=H256>> Backend<Block> {
|
||||
);
|
||||
|
||||
transaction.put(columns::HEADER, &lookup_key, &pending_block.header.encode());
|
||||
if let Some(body) = &pending_block.body {
|
||||
if let Some(body) = pending_block.body {
|
||||
transaction.put(columns::BODY, &lookup_key, &body.encode());
|
||||
}
|
||||
if let Some(justification) = pending_block.justification {
|
||||
@@ -1133,26 +1127,21 @@ impl<Block: BlockT<Hash=H256>> Backend<Block> {
|
||||
transaction.put(columns::META, meta_keys::GENESIS_HASH, hash.as_ref());
|
||||
}
|
||||
|
||||
let finalized = if pending_block.body.is_some() {
|
||||
let mut changeset: state_db::ChangeSet<Vec<u8>> = state_db::ChangeSet::default();
|
||||
for (key, (val, rc)) in operation.db_updates.drain() {
|
||||
if rc > 0 {
|
||||
changeset.inserted.push((key, val.to_vec()));
|
||||
} else if rc < 0 {
|
||||
changeset.deleted.push(key);
|
||||
}
|
||||
let mut changeset: state_db::ChangeSet<Vec<u8>> = state_db::ChangeSet::default();
|
||||
for (key, (val, rc)) in operation.db_updates.drain() {
|
||||
if rc > 0 {
|
||||
changeset.inserted.push((key, val.to_vec()));
|
||||
} else if rc < 0 {
|
||||
changeset.deleted.push(key);
|
||||
}
|
||||
let number_u64 = number.saturated_into::<u64>();
|
||||
let commit = self.storage.state_db.insert_block(&hash, number_u64, &pending_block.header.parent_hash(), changeset)
|
||||
.map_err(|e: state_db::Error<io::Error>| client::error::Error::from(format!("State database error: {:?}", e)))?;
|
||||
apply_state_commit(&mut transaction, commit);
|
||||
}
|
||||
let number_u64 = number.saturated_into::<u64>();
|
||||
let commit = self.storage.state_db.insert_block(&hash, number_u64, &pending_block.header.parent_hash(), changeset)
|
||||
.map_err(|e: state_db::Error<io::Error>| client::error::Error::from(format!("State database error: {:?}", e)))?;
|
||||
apply_state_commit(&mut transaction, commit);
|
||||
|
||||
// Check if need to finalize. Genesis is always finalized instantly.
|
||||
let finalized = number_u64 == 0 || pending_block.leaf_state.is_final();
|
||||
finalized
|
||||
} else {
|
||||
false
|
||||
};
|
||||
// Check if need to finalize. Genesis is always finalized instantly.
|
||||
let finalized = number_u64 == 0 || pending_block.leaf_state.is_final();
|
||||
|
||||
let header = &pending_block.header;
|
||||
let is_best = pending_block.leaf_state.is_best();
|
||||
@@ -1592,7 +1581,7 @@ mod tests {
|
||||
};
|
||||
let mut op = backend.begin_operation().unwrap();
|
||||
backend.begin_state_operation(&mut op, block_id).unwrap();
|
||||
op.set_block_data(header, Some(Vec::new()), None, NewBlockState::Best).unwrap();
|
||||
op.set_block_data(header, None, None, NewBlockState::Best).unwrap();
|
||||
op.update_changes_trie((changes_trie_update, ChangesTrieCacheAction::Clear)).unwrap();
|
||||
backend.commit_operation(op).unwrap();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user