mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-28 16:47:57 +00:00
BlockId removal: &Hash to Hash (#12626)
It changes &Block::Hash argument to Block::Hash. This PR is part of BlockId::Number refactoring analysis (paritytech/substrate#11292)
This commit is contained in:
committed by
GitHub
parent
7c4bfc9749
commit
1ed70004e7
+150
-150
@@ -577,9 +577,9 @@ impl<Block: BlockT> sc_client_api::blockchain::HeaderBackend<Block> for Blockcha
|
||||
}
|
||||
|
||||
impl<Block: BlockT> sc_client_api::blockchain::Backend<Block> for BlockchainDb<Block> {
|
||||
fn body(&self, hash: &Block::Hash) -> ClientResult<Option<Vec<Block::Extrinsic>>> {
|
||||
fn body(&self, hash: Block::Hash) -> ClientResult<Option<Vec<Block::Extrinsic>>> {
|
||||
if let Some(body) =
|
||||
read_db(&*self.db, columns::KEY_LOOKUP, columns::BODY, BlockId::Hash::<Block>(*hash))?
|
||||
read_db(&*self.db, columns::KEY_LOOKUP, columns::BODY, BlockId::Hash::<Block>(hash))?
|
||||
{
|
||||
// Plain body
|
||||
match Decode::decode(&mut &body[..]) {
|
||||
@@ -596,7 +596,7 @@ impl<Block: BlockT> sc_client_api::blockchain::Backend<Block> for BlockchainDb<B
|
||||
&*self.db,
|
||||
columns::KEY_LOOKUP,
|
||||
columns::BODY_INDEX,
|
||||
BlockId::Hash::<Block>(*hash),
|
||||
BlockId::Hash::<Block>(hash),
|
||||
)? {
|
||||
match Vec::<DbExtrinsic<Block>>::decode(&mut &index[..]) {
|
||||
Ok(index) => {
|
||||
@@ -642,12 +642,12 @@ impl<Block: BlockT> sc_client_api::blockchain::Backend<Block> for BlockchainDb<B
|
||||
Ok(None)
|
||||
}
|
||||
|
||||
fn justifications(&self, hash: &Block::Hash) -> ClientResult<Option<Justifications>> {
|
||||
fn justifications(&self, hash: Block::Hash) -> ClientResult<Option<Justifications>> {
|
||||
match read_db(
|
||||
&*self.db,
|
||||
columns::KEY_LOOKUP,
|
||||
columns::JUSTIFICATIONS,
|
||||
BlockId::<Block>::Hash(*hash),
|
||||
BlockId::<Block>::Hash(hash),
|
||||
)? {
|
||||
Some(justifications) => match Decode::decode(&mut &justifications[..]) {
|
||||
Ok(justifications) => Ok(Some(justifications)),
|
||||
@@ -686,20 +686,20 @@ impl<Block: BlockT> sc_client_api::blockchain::Backend<Block> for BlockchainDb<B
|
||||
children::read_children(&*self.db, columns::META, meta_keys::CHILDREN_PREFIX, parent_hash)
|
||||
}
|
||||
|
||||
fn indexed_transaction(&self, hash: &Block::Hash) -> ClientResult<Option<Vec<u8>>> {
|
||||
fn indexed_transaction(&self, hash: Block::Hash) -> ClientResult<Option<Vec<u8>>> {
|
||||
Ok(self.db.get(columns::TRANSACTION, hash.as_ref()))
|
||||
}
|
||||
|
||||
fn has_indexed_transaction(&self, hash: &Block::Hash) -> ClientResult<bool> {
|
||||
fn has_indexed_transaction(&self, hash: Block::Hash) -> ClientResult<bool> {
|
||||
Ok(self.db.contains(columns::TRANSACTION, hash.as_ref()))
|
||||
}
|
||||
|
||||
fn block_indexed_body(&self, hash: &Block::Hash) -> ClientResult<Option<Vec<Vec<u8>>>> {
|
||||
fn block_indexed_body(&self, hash: Block::Hash) -> ClientResult<Option<Vec<Vec<u8>>>> {
|
||||
let body = match read_db(
|
||||
&*self.db,
|
||||
columns::KEY_LOOKUP,
|
||||
columns::BODY_INDEX,
|
||||
BlockId::<Block>::Hash(*hash),
|
||||
BlockId::<Block>::Hash(hash),
|
||||
)? {
|
||||
Some(body) => body,
|
||||
None => return Ok(None),
|
||||
@@ -914,16 +914,16 @@ impl<Block: BlockT> sc_client_api::backend::BlockImportOperation<Block>
|
||||
|
||||
fn mark_finalized(
|
||||
&mut self,
|
||||
block: &Block::Hash,
|
||||
block: Block::Hash,
|
||||
justification: Option<Justification>,
|
||||
) -> ClientResult<()> {
|
||||
self.finalized_blocks.push((*block, justification));
|
||||
self.finalized_blocks.push((block, justification));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn mark_head(&mut self, hash: &Block::Hash) -> ClientResult<()> {
|
||||
fn mark_head(&mut self, hash: Block::Hash) -> ClientResult<()> {
|
||||
assert!(self.set_head.is_none(), "Only one set head per operation is allowed");
|
||||
self.set_head = Some(*hash);
|
||||
self.set_head = Some(hash);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -1176,7 +1176,7 @@ impl<Block: BlockT> Backend<Block> {
|
||||
info.finalized_hash != Default::default() &&
|
||||
sc_client_api::Backend::have_state_at(
|
||||
&backend,
|
||||
&info.finalized_hash,
|
||||
info.finalized_hash,
|
||||
info.finalized_number,
|
||||
) {
|
||||
backend.blockchain.update_meta(MetaUpdate {
|
||||
@@ -1289,7 +1289,7 @@ impl<Block: BlockT> Backend<Block> {
|
||||
fn finalize_block_with_transaction(
|
||||
&self,
|
||||
transaction: &mut Transaction<DbHash>,
|
||||
hash: &Block::Hash,
|
||||
hash: Block::Hash,
|
||||
header: &Block::Header,
|
||||
last_finalized: Option<Block::Hash>,
|
||||
justification: Option<Justification>,
|
||||
@@ -1300,7 +1300,7 @@ impl<Block: BlockT> Backend<Block> {
|
||||
self.ensure_sequential_finalization(header, last_finalized)?;
|
||||
let with_state = sc_client_api::Backend::have_state_at(self, hash, number);
|
||||
|
||||
self.note_finalized(transaction, header, *hash, finalization_displaced, with_state)?;
|
||||
self.note_finalized(transaction, header, hash, finalization_displaced, with_state)?;
|
||||
|
||||
if let Some(justification) = justification {
|
||||
transaction.set_from_vec(
|
||||
@@ -1309,7 +1309,7 @@ impl<Block: BlockT> Backend<Block> {
|
||||
Justifications::from(justification).encode(),
|
||||
);
|
||||
}
|
||||
Ok(MetaUpdate { hash: *hash, number, is_best: false, is_finalized: true, with_state })
|
||||
Ok(MetaUpdate { hash, number, is_best: false, is_finalized: true, with_state })
|
||||
}
|
||||
|
||||
// performs forced canonicalization with a delay after importing a non-finalized block.
|
||||
@@ -1340,7 +1340,7 @@ impl<Block: BlockT> Backend<Block> {
|
||||
))
|
||||
})?
|
||||
};
|
||||
if !sc_client_api::Backend::have_state_at(self, &hash, new_canonical.saturated_into()) {
|
||||
if !sc_client_api::Backend::have_state_at(self, hash, new_canonical.saturated_into()) {
|
||||
return Ok(())
|
||||
}
|
||||
|
||||
@@ -1372,7 +1372,7 @@ impl<Block: BlockT> Backend<Block> {
|
||||
let block_header = self.blockchain.expect_header(BlockId::Hash(block_hash))?;
|
||||
meta_updates.push(self.finalize_block_with_transaction(
|
||||
&mut transaction,
|
||||
&block_hash,
|
||||
block_hash,
|
||||
&block_header,
|
||||
Some(last_finalized_hash),
|
||||
justification,
|
||||
@@ -1703,7 +1703,7 @@ impl<Block: BlockT> Backend<Block> {
|
||||
}
|
||||
transaction.set_from_vec(columns::META, meta_keys::FINALIZED_BLOCK, lookup_key);
|
||||
|
||||
if sc_client_api::Backend::have_state_at(self, &f_hash, f_num) &&
|
||||
if sc_client_api::Backend::have_state_at(self, f_hash, f_num) &&
|
||||
self.storage
|
||||
.state_db
|
||||
.best_canonical()
|
||||
@@ -1978,9 +1978,9 @@ impl<Block: BlockT> sc_client_api::backend::Backend<Block> for Backend<Block> {
|
||||
fn begin_state_operation(
|
||||
&self,
|
||||
operation: &mut Self::BlockImportOperation,
|
||||
block: &Block::Hash,
|
||||
block: Block::Hash,
|
||||
) -> ClientResult<()> {
|
||||
if *block == Default::default() {
|
||||
if block == Default::default() {
|
||||
operation.old_state = self.empty_state()?;
|
||||
} else {
|
||||
operation.old_state = self.state_at(block)?;
|
||||
@@ -2008,11 +2008,11 @@ impl<Block: BlockT> sc_client_api::backend::Backend<Block> for Backend<Block> {
|
||||
|
||||
fn finalize_block(
|
||||
&self,
|
||||
hash: &Block::Hash,
|
||||
hash: Block::Hash,
|
||||
justification: Option<Justification>,
|
||||
) -> ClientResult<()> {
|
||||
let mut transaction = Transaction::new();
|
||||
let header = self.blockchain.expect_header(BlockId::Hash(*hash))?;
|
||||
let header = self.blockchain.expect_header(BlockId::Hash(hash))?;
|
||||
let mut displaced = None;
|
||||
|
||||
let m = self.finalize_block_with_transaction(
|
||||
@@ -2030,11 +2030,11 @@ impl<Block: BlockT> sc_client_api::backend::Backend<Block> for Backend<Block> {
|
||||
|
||||
fn append_justification(
|
||||
&self,
|
||||
hash: &Block::Hash,
|
||||
hash: Block::Hash,
|
||||
justification: Justification,
|
||||
) -> ClientResult<()> {
|
||||
let mut transaction: Transaction<DbHash> = Transaction::new();
|
||||
let header = self.blockchain.expect_header(BlockId::Hash(*hash))?;
|
||||
let header = self.blockchain.expect_header(BlockId::Hash(hash))?;
|
||||
let number = *header.number();
|
||||
|
||||
// Check if the block is finalized first.
|
||||
@@ -2043,7 +2043,7 @@ impl<Block: BlockT> sc_client_api::backend::Backend<Block> for Backend<Block> {
|
||||
|
||||
// We can do a quick check first, before doing a proper but more expensive check
|
||||
if number > self.blockchain.info().finalized_number ||
|
||||
(*hash != last_finalized && !is_descendent_of(hash, &last_finalized)?)
|
||||
(hash != last_finalized && !is_descendent_of(&hash, &last_finalized)?)
|
||||
{
|
||||
return Err(ClientError::NotInFinalizedChain)
|
||||
}
|
||||
@@ -2061,7 +2061,7 @@ impl<Block: BlockT> sc_client_api::backend::Backend<Block> for Backend<Block> {
|
||||
|
||||
transaction.set_from_vec(
|
||||
columns::JUSTIFICATIONS,
|
||||
&utils::number_and_hash_to_lookup_key(number, *hash)?,
|
||||
&utils::number_and_hash_to_lookup_key(number, hash)?,
|
||||
justifications.encode(),
|
||||
);
|
||||
|
||||
@@ -2154,7 +2154,7 @@ impl<Block: BlockT> sc_client_api::backend::Backend<Block> for Backend<Block> {
|
||||
let prev_hash =
|
||||
if prev_number == best_number { best_hash } else { *removed.parent_hash() };
|
||||
|
||||
if !self.have_state_at(&prev_hash, prev_number) {
|
||||
if !self.have_state_at(prev_hash, prev_number) {
|
||||
return Ok(c.saturated_into::<NumberFor<Block>>())
|
||||
}
|
||||
|
||||
@@ -2183,7 +2183,7 @@ impl<Block: BlockT> sc_client_api::backend::Backend<Block> for Backend<Block> {
|
||||
if hash == hash_to_revert {
|
||||
if !number_to_revert.is_zero() &&
|
||||
self.have_state_at(
|
||||
&prev_hash,
|
||||
prev_hash,
|
||||
number_to_revert - One::one(),
|
||||
) {
|
||||
let lookup_key = utils::number_and_hash_to_lookup_key(
|
||||
@@ -2247,14 +2247,14 @@ impl<Block: BlockT> sc_client_api::backend::Backend<Block> for Backend<Block> {
|
||||
Ok((reverted, reverted_finalized))
|
||||
}
|
||||
|
||||
fn remove_leaf_block(&self, hash: &Block::Hash) -> ClientResult<()> {
|
||||
fn remove_leaf_block(&self, hash: Block::Hash) -> ClientResult<()> {
|
||||
let best_hash = self.blockchain.info().best_hash;
|
||||
|
||||
if best_hash == *hash {
|
||||
if best_hash == hash {
|
||||
return Err(sp_blockchain::Error::Backend(format!("Can't remove best block {:?}", hash)))
|
||||
}
|
||||
|
||||
let hdr = self.blockchain.header_metadata(*hash)?;
|
||||
let hdr = self.blockchain.header_metadata(hash)?;
|
||||
if !self.have_state_at(hash, hdr.number) {
|
||||
return Err(sp_blockchain::Error::UnknownBlock(format!(
|
||||
"State already discarded for {:?}",
|
||||
@@ -2263,7 +2263,7 @@ impl<Block: BlockT> sc_client_api::backend::Backend<Block> for Backend<Block> {
|
||||
}
|
||||
|
||||
let mut leaves = self.blockchain.leaves.write();
|
||||
if !leaves.contains(hdr.number, *hash) {
|
||||
if !leaves.contains(hdr.number, hash) {
|
||||
return Err(sp_blockchain::Error::Backend(format!(
|
||||
"Can't remove non-leaf block {:?}",
|
||||
hash
|
||||
@@ -2271,7 +2271,7 @@ impl<Block: BlockT> sc_client_api::backend::Backend<Block> for Backend<Block> {
|
||||
}
|
||||
|
||||
let mut transaction = Transaction::new();
|
||||
if let Some(commit) = self.storage.state_db.remove(hash) {
|
||||
if let Some(commit) = self.storage.state_db.remove(&hash) {
|
||||
apply_state_commit(&mut transaction, commit);
|
||||
}
|
||||
transaction.remove(columns::KEY_LOOKUP, hash.as_ref());
|
||||
@@ -2280,7 +2280,7 @@ impl<Block: BlockT> sc_client_api::backend::Backend<Block> for Backend<Block> {
|
||||
.blockchain()
|
||||
.children(hdr.parent)?
|
||||
.into_iter()
|
||||
.filter(|child_hash| child_hash != hash)
|
||||
.filter(|child_hash| *child_hash != hash)
|
||||
.collect();
|
||||
let parent_leaf = if children.is_empty() {
|
||||
children::remove_children(
|
||||
@@ -2301,7 +2301,7 @@ impl<Block: BlockT> sc_client_api::backend::Backend<Block> for Backend<Block> {
|
||||
None
|
||||
};
|
||||
|
||||
let remove_outcome = leaves.remove(*hash, hdr.number, parent_leaf);
|
||||
let remove_outcome = leaves.remove(hash, hdr.number, parent_leaf);
|
||||
leaves.prepare_transaction(&mut transaction, columns::META, meta_keys::LEAF_PREFIX);
|
||||
if let Err(e) = self.storage.db.commit(transaction) {
|
||||
if let Some(outcome) = remove_outcome {
|
||||
@@ -2309,7 +2309,7 @@ impl<Block: BlockT> sc_client_api::backend::Backend<Block> for Backend<Block> {
|
||||
}
|
||||
return Err(e.into())
|
||||
}
|
||||
self.blockchain().remove_header_metadata(*hash);
|
||||
self.blockchain().remove_header_metadata(hash);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -2317,8 +2317,8 @@ impl<Block: BlockT> sc_client_api::backend::Backend<Block> for Backend<Block> {
|
||||
&self.blockchain
|
||||
}
|
||||
|
||||
fn state_at(&self, hash: &Block::Hash) -> ClientResult<Self::State> {
|
||||
if hash == &self.blockchain.meta.read().genesis_hash {
|
||||
fn state_at(&self, hash: Block::Hash) -> ClientResult<Self::State> {
|
||||
if hash == self.blockchain.meta.read().genesis_hash {
|
||||
if let Some(genesis_state) = &*self.genesis_state.read() {
|
||||
let root = genesis_state.root;
|
||||
let db_state = DbStateBuilder::<Block>::new(genesis_state.clone(), root)
|
||||
@@ -2330,7 +2330,7 @@ impl<Block: BlockT> sc_client_api::backend::Backend<Block> for Backend<Block> {
|
||||
}
|
||||
}
|
||||
|
||||
match self.blockchain.header_metadata(*hash) {
|
||||
match self.blockchain.header_metadata(hash) {
|
||||
Ok(ref hdr) => {
|
||||
let hint = || {
|
||||
sc_state_db::NodeDb::get(self.storage.as_ref(), hdr.state_root.as_ref())
|
||||
@@ -2338,7 +2338,7 @@ impl<Block: BlockT> sc_client_api::backend::Backend<Block> for Backend<Block> {
|
||||
.is_some()
|
||||
};
|
||||
if let Ok(()) =
|
||||
self.storage.state_db.pin(hash, hdr.number.saturated_into::<u64>(), hint)
|
||||
self.storage.state_db.pin(&hash, hdr.number.saturated_into::<u64>(), hint)
|
||||
{
|
||||
let root = hdr.state_root;
|
||||
let db_state = DbStateBuilder::<Block>::new(self.storage.clone(), root)
|
||||
@@ -2346,8 +2346,8 @@ impl<Block: BlockT> sc_client_api::backend::Backend<Block> for Backend<Block> {
|
||||
self.shared_trie_cache.as_ref().map(|c| c.local_cache()),
|
||||
)
|
||||
.build();
|
||||
let state = RefTrackingState::new(db_state, self.storage.clone(), Some(*hash));
|
||||
Ok(RecordStatsState::new(state, Some(*hash), self.state_usage.clone()))
|
||||
let state = RefTrackingState::new(db_state, self.storage.clone(), Some(hash));
|
||||
Ok(RecordStatsState::new(state, Some(hash), self.state_usage.clone()))
|
||||
} else {
|
||||
Err(sp_blockchain::Error::UnknownBlock(format!(
|
||||
"State already discarded for {:?}",
|
||||
@@ -2359,9 +2359,9 @@ impl<Block: BlockT> sc_client_api::backend::Backend<Block> for Backend<Block> {
|
||||
}
|
||||
}
|
||||
|
||||
fn have_state_at(&self, hash: &Block::Hash, number: NumberFor<Block>) -> bool {
|
||||
fn have_state_at(&self, hash: Block::Hash, number: NumberFor<Block>) -> bool {
|
||||
if self.is_archive {
|
||||
match self.blockchain.header_metadata(*hash) {
|
||||
match self.blockchain.header_metadata(hash) {
|
||||
Ok(header) => sp_state_machine::Storage::get(
|
||||
self.storage.as_ref(),
|
||||
&header.state_root,
|
||||
@@ -2372,10 +2372,10 @@ impl<Block: BlockT> sc_client_api::backend::Backend<Block> for Backend<Block> {
|
||||
_ => false,
|
||||
}
|
||||
} else {
|
||||
match self.storage.state_db.is_pruned(hash, number.saturated_into::<u64>()) {
|
||||
match self.storage.state_db.is_pruned(&hash, number.saturated_into::<u64>()) {
|
||||
IsPruned::Pruned => false,
|
||||
IsPruned::NotPruned => true,
|
||||
IsPruned::MaybePruned => match self.blockchain.header_metadata(*hash) {
|
||||
IsPruned::MaybePruned => match self.blockchain.header_metadata(hash) {
|
||||
Ok(header) => sp_state_machine::Storage::get(
|
||||
self.storage.as_ref(),
|
||||
&header.state_root,
|
||||
@@ -2459,7 +2459,7 @@ pub(crate) mod tests {
|
||||
|
||||
let block_hash = if number == 0 { Default::default() } else { parent_hash };
|
||||
let mut op = backend.begin_operation().unwrap();
|
||||
backend.begin_state_operation(&mut op, &block_hash).unwrap();
|
||||
backend.begin_state_operation(&mut op, block_hash).unwrap();
|
||||
op.set_block_data(header, Some(body), None, None, NewBlockState::Best).unwrap();
|
||||
if let Some(index) = transaction_index {
|
||||
op.update_transaction_index(index).unwrap();
|
||||
@@ -2507,7 +2507,7 @@ pub(crate) mod tests {
|
||||
};
|
||||
|
||||
let mut op = db.begin_operation().unwrap();
|
||||
db.begin_state_operation(&mut op, &hash).unwrap();
|
||||
db.begin_state_operation(&mut op, hash).unwrap();
|
||||
let header = Header {
|
||||
number: i,
|
||||
parent_hash: hash,
|
||||
@@ -2581,7 +2581,7 @@ pub(crate) mod tests {
|
||||
|
||||
db.commit_operation(op).unwrap();
|
||||
|
||||
let state = db.state_at(&hash).unwrap();
|
||||
let state = db.state_at(hash).unwrap();
|
||||
|
||||
assert_eq!(state.storage(&[1, 3, 5]).unwrap(), Some(vec![2, 4, 6]));
|
||||
assert_eq!(state.storage(&[1, 2, 3]).unwrap(), Some(vec![9, 9, 9]));
|
||||
@@ -2592,7 +2592,7 @@ pub(crate) mod tests {
|
||||
|
||||
{
|
||||
let mut op = db.begin_operation().unwrap();
|
||||
db.begin_state_operation(&mut op, &hash).unwrap();
|
||||
db.begin_state_operation(&mut op, hash).unwrap();
|
||||
let mut header = Header {
|
||||
number: 1,
|
||||
parent_hash: hash,
|
||||
@@ -2616,7 +2616,7 @@ pub(crate) mod tests {
|
||||
|
||||
db.commit_operation(op).unwrap();
|
||||
|
||||
let state = db.state_at(&header.hash()).unwrap();
|
||||
let state = db.state_at(header.hash()).unwrap();
|
||||
|
||||
assert_eq!(state.storage(&[1, 3, 5]).unwrap(), None);
|
||||
assert_eq!(state.storage(&[1, 2, 3]).unwrap(), Some(vec![9, 9, 9]));
|
||||
@@ -2633,7 +2633,7 @@ pub(crate) mod tests {
|
||||
|
||||
let hash = {
|
||||
let mut op = backend.begin_operation().unwrap();
|
||||
backend.begin_state_operation(&mut op, &Default::default()).unwrap();
|
||||
backend.begin_state_operation(&mut op, Default::default()).unwrap();
|
||||
let mut header = Header {
|
||||
number: 0,
|
||||
parent_hash: Default::default(),
|
||||
@@ -2670,7 +2670,7 @@ pub(crate) mod tests {
|
||||
|
||||
let hashof1 = {
|
||||
let mut op = backend.begin_operation().unwrap();
|
||||
backend.begin_state_operation(&mut op, &hash).unwrap();
|
||||
backend.begin_state_operation(&mut op, hash).unwrap();
|
||||
let mut header = Header {
|
||||
number: 1,
|
||||
parent_hash: hash,
|
||||
@@ -2707,7 +2707,7 @@ pub(crate) mod tests {
|
||||
|
||||
let hashof2 = {
|
||||
let mut op = backend.begin_operation().unwrap();
|
||||
backend.begin_state_operation(&mut op, &hashof1).unwrap();
|
||||
backend.begin_state_operation(&mut op, hashof1).unwrap();
|
||||
let mut header = Header {
|
||||
number: 2,
|
||||
parent_hash: hashof1,
|
||||
@@ -2741,7 +2741,7 @@ pub(crate) mod tests {
|
||||
|
||||
let hashof3 = {
|
||||
let mut op = backend.begin_operation().unwrap();
|
||||
backend.begin_state_operation(&mut op, &hashof2).unwrap();
|
||||
backend.begin_state_operation(&mut op, hashof2).unwrap();
|
||||
let mut header = Header {
|
||||
number: 3,
|
||||
parent_hash: hashof2,
|
||||
@@ -2771,9 +2771,9 @@ pub(crate) mod tests {
|
||||
hash
|
||||
};
|
||||
|
||||
backend.finalize_block(&hashof1, None).unwrap();
|
||||
backend.finalize_block(&hashof2, None).unwrap();
|
||||
backend.finalize_block(&hashof3, None).unwrap();
|
||||
backend.finalize_block(hashof1, None).unwrap();
|
||||
backend.finalize_block(hashof2, None).unwrap();
|
||||
backend.finalize_block(hashof3, None).unwrap();
|
||||
assert!(backend
|
||||
.storage
|
||||
.db
|
||||
@@ -2996,8 +2996,8 @@ pub(crate) mod tests {
|
||||
vec![block2_a, block2_b, block2_c, block1_c]
|
||||
);
|
||||
|
||||
backend.finalize_block(&block1_a, None).unwrap();
|
||||
backend.finalize_block(&block2_a, None).unwrap();
|
||||
backend.finalize_block(block1_a, None).unwrap();
|
||||
backend.finalize_block(block2_a, None).unwrap();
|
||||
|
||||
// leaves at same height stay. Leaves at lower heights pruned.
|
||||
assert_eq!(backend.blockchain().leaves().unwrap(), vec![block2_a, block2_b, block2_c]);
|
||||
@@ -3024,10 +3024,10 @@ pub(crate) mod tests {
|
||||
let block1 = insert_header(&backend, 1, block0, None, Default::default());
|
||||
|
||||
let justification = Some((CONS0_ENGINE_ID, vec![1, 2, 3]));
|
||||
backend.finalize_block(&block1, justification.clone()).unwrap();
|
||||
backend.finalize_block(block1, justification.clone()).unwrap();
|
||||
|
||||
assert_eq!(
|
||||
backend.blockchain().justifications(&block1).unwrap(),
|
||||
backend.blockchain().justifications(block1).unwrap(),
|
||||
justification.map(Justifications::from),
|
||||
);
|
||||
}
|
||||
@@ -3042,14 +3042,14 @@ pub(crate) mod tests {
|
||||
let block1 = insert_header(&backend, 1, block0, None, Default::default());
|
||||
|
||||
let just0 = (CONS0_ENGINE_ID, vec![1, 2, 3]);
|
||||
backend.finalize_block(&block1, Some(just0.clone().into())).unwrap();
|
||||
backend.finalize_block(block1, Some(just0.clone().into())).unwrap();
|
||||
|
||||
let just1 = (CONS1_ENGINE_ID, vec![4, 5]);
|
||||
backend.append_justification(&block1, just1.clone()).unwrap();
|
||||
backend.append_justification(block1, just1.clone()).unwrap();
|
||||
|
||||
let just2 = (CONS1_ENGINE_ID, vec![6, 7]);
|
||||
assert!(matches!(
|
||||
backend.append_justification(&block1, just2),
|
||||
backend.append_justification(block1, just2),
|
||||
Err(ClientError::BadJustification(_))
|
||||
));
|
||||
|
||||
@@ -3058,7 +3058,7 @@ pub(crate) mod tests {
|
||||
just.append(just1);
|
||||
just
|
||||
};
|
||||
assert_eq!(backend.blockchain().justifications(&block1).unwrap(), Some(justifications),);
|
||||
assert_eq!(backend.blockchain().justifications(block1).unwrap(), Some(justifications),);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -3072,16 +3072,16 @@ pub(crate) mod tests {
|
||||
let block4 = insert_header(&backend, 4, block3, None, Default::default());
|
||||
{
|
||||
let mut op = backend.begin_operation().unwrap();
|
||||
backend.begin_state_operation(&mut op, &block0).unwrap();
|
||||
op.mark_finalized(&block1, None).unwrap();
|
||||
op.mark_finalized(&block2, None).unwrap();
|
||||
backend.begin_state_operation(&mut op, block0).unwrap();
|
||||
op.mark_finalized(block1, None).unwrap();
|
||||
op.mark_finalized(block2, None).unwrap();
|
||||
backend.commit_operation(op).unwrap();
|
||||
}
|
||||
{
|
||||
let mut op = backend.begin_operation().unwrap();
|
||||
backend.begin_state_operation(&mut op, &block2).unwrap();
|
||||
op.mark_finalized(&block3, None).unwrap();
|
||||
op.mark_finalized(&block4, None).unwrap();
|
||||
backend.begin_state_operation(&mut op, block2).unwrap();
|
||||
op.mark_finalized(block3, None).unwrap();
|
||||
op.mark_finalized(block4, None).unwrap();
|
||||
backend.commit_operation(op).unwrap();
|
||||
}
|
||||
}
|
||||
@@ -3093,7 +3093,7 @@ pub(crate) mod tests {
|
||||
|
||||
let hash0 = {
|
||||
let mut op = backend.begin_operation().unwrap();
|
||||
backend.begin_state_operation(&mut op, &Default::default()).unwrap();
|
||||
backend.begin_state_operation(&mut op, Default::default()).unwrap();
|
||||
let mut header = Header {
|
||||
number: 0,
|
||||
parent_hash: Default::default(),
|
||||
@@ -3127,11 +3127,11 @@ pub(crate) mod tests {
|
||||
hash
|
||||
};
|
||||
|
||||
let block0_hash = backend.state_at(&hash0).unwrap().storage_hash(&b"test"[..]).unwrap();
|
||||
let block0_hash = backend.state_at(hash0).unwrap().storage_hash(&b"test"[..]).unwrap();
|
||||
|
||||
let hash1 = {
|
||||
let mut op = backend.begin_operation().unwrap();
|
||||
backend.begin_state_operation(&mut op, &hash0).unwrap();
|
||||
backend.begin_state_operation(&mut op, hash0).unwrap();
|
||||
let mut header = Header {
|
||||
number: 1,
|
||||
parent_hash: hash0,
|
||||
@@ -3166,7 +3166,7 @@ pub(crate) mod tests {
|
||||
backend.commit_operation(op).unwrap();
|
||||
}
|
||||
|
||||
let block1_hash = backend.state_at(&hash1).unwrap().storage_hash(&b"test"[..]).unwrap();
|
||||
let block1_hash = backend.state_at(hash1).unwrap().storage_hash(&b"test"[..]).unwrap();
|
||||
|
||||
assert_ne!(block0_hash, block1_hash);
|
||||
}
|
||||
@@ -3180,8 +3180,8 @@ pub(crate) mod tests {
|
||||
let block2 = insert_header(&backend, 2, block1, None, Default::default());
|
||||
{
|
||||
let mut op = backend.begin_operation().unwrap();
|
||||
backend.begin_state_operation(&mut op, &block0).unwrap();
|
||||
op.mark_finalized(&block2, None).unwrap();
|
||||
backend.begin_state_operation(&mut op, block0).unwrap();
|
||||
op.mark_finalized(block2, None).unwrap();
|
||||
backend.commit_operation(op).unwrap_err();
|
||||
}
|
||||
}
|
||||
@@ -3208,18 +3208,18 @@ pub(crate) mod tests {
|
||||
|
||||
{
|
||||
let mut op = backend.begin_operation().unwrap();
|
||||
backend.begin_state_operation(&mut op, &blocks[4]).unwrap();
|
||||
backend.begin_state_operation(&mut op, blocks[4]).unwrap();
|
||||
for i in 1..5 {
|
||||
op.mark_finalized(&blocks[i], None).unwrap();
|
||||
op.mark_finalized(blocks[i], None).unwrap();
|
||||
}
|
||||
backend.commit_operation(op).unwrap();
|
||||
}
|
||||
let bc = backend.blockchain();
|
||||
assert_eq!(None, bc.body(&blocks[0]).unwrap());
|
||||
assert_eq!(None, bc.body(&blocks[1]).unwrap());
|
||||
assert_eq!(None, bc.body(&blocks[2]).unwrap());
|
||||
assert_eq!(Some(vec![3.into()]), bc.body(&blocks[3]).unwrap());
|
||||
assert_eq!(Some(vec![4.into()]), bc.body(&blocks[4]).unwrap());
|
||||
assert_eq!(None, bc.body(blocks[0]).unwrap());
|
||||
assert_eq!(None, bc.body(blocks[1]).unwrap());
|
||||
assert_eq!(None, bc.body(blocks[2]).unwrap());
|
||||
assert_eq!(Some(vec![3.into()]), bc.body(blocks[3]).unwrap());
|
||||
assert_eq!(Some(vec![4.into()]), bc.body(blocks[4]).unwrap());
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -3243,18 +3243,18 @@ pub(crate) mod tests {
|
||||
}
|
||||
|
||||
let mut op = backend.begin_operation().unwrap();
|
||||
backend.begin_state_operation(&mut op, &blocks[4]).unwrap();
|
||||
backend.begin_state_operation(&mut op, blocks[4]).unwrap();
|
||||
for i in 1..3 {
|
||||
op.mark_finalized(&blocks[i], None).unwrap();
|
||||
op.mark_finalized(blocks[i], None).unwrap();
|
||||
}
|
||||
backend.commit_operation(op).unwrap();
|
||||
|
||||
let bc = backend.blockchain();
|
||||
assert_eq!(Some(vec![0.into()]), bc.body(&blocks[0]).unwrap());
|
||||
assert_eq!(Some(vec![1.into()]), bc.body(&blocks[1]).unwrap());
|
||||
assert_eq!(Some(vec![2.into()]), bc.body(&blocks[2]).unwrap());
|
||||
assert_eq!(Some(vec![3.into()]), bc.body(&blocks[3]).unwrap());
|
||||
assert_eq!(Some(vec![4.into()]), bc.body(&blocks[4]).unwrap());
|
||||
assert_eq!(Some(vec![0.into()]), bc.body(blocks[0]).unwrap());
|
||||
assert_eq!(Some(vec![1.into()]), bc.body(blocks[1]).unwrap());
|
||||
assert_eq!(Some(vec![2.into()]), bc.body(blocks[2]).unwrap());
|
||||
assert_eq!(Some(vec![3.into()]), bc.body(blocks[3]).unwrap());
|
||||
assert_eq!(Some(vec![4.into()]), bc.body(blocks[4]).unwrap());
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -3300,27 +3300,27 @@ pub(crate) mod tests {
|
||||
.unwrap();
|
||||
|
||||
let mut op = backend.begin_operation().unwrap();
|
||||
backend.begin_state_operation(&mut op, &blocks[4]).unwrap();
|
||||
op.mark_head(&blocks[4]).unwrap();
|
||||
backend.begin_state_operation(&mut op, blocks[4]).unwrap();
|
||||
op.mark_head(blocks[4]).unwrap();
|
||||
backend.commit_operation(op).unwrap();
|
||||
|
||||
let bc = backend.blockchain();
|
||||
assert_eq!(Some(vec![2.into()]), bc.body(&fork_hash_root).unwrap());
|
||||
assert_eq!(Some(vec![2.into()]), bc.body(fork_hash_root).unwrap());
|
||||
|
||||
for i in 1..5 {
|
||||
let mut op = backend.begin_operation().unwrap();
|
||||
backend.begin_state_operation(&mut op, &blocks[i]).unwrap();
|
||||
op.mark_finalized(&blocks[i], None).unwrap();
|
||||
backend.begin_state_operation(&mut op, blocks[i]).unwrap();
|
||||
op.mark_finalized(blocks[i], None).unwrap();
|
||||
backend.commit_operation(op).unwrap();
|
||||
}
|
||||
|
||||
assert_eq!(Some(vec![0.into()]), bc.body(&blocks[0]).unwrap());
|
||||
assert_eq!(Some(vec![1.into()]), bc.body(&blocks[1]).unwrap());
|
||||
assert_eq!(Some(vec![2.into()]), bc.body(&blocks[2]).unwrap());
|
||||
assert_eq!(Some(vec![3.into()]), bc.body(&blocks[3]).unwrap());
|
||||
assert_eq!(Some(vec![4.into()]), bc.body(&blocks[4]).unwrap());
|
||||
assert_eq!(Some(vec![0.into()]), bc.body(blocks[0]).unwrap());
|
||||
assert_eq!(Some(vec![1.into()]), bc.body(blocks[1]).unwrap());
|
||||
assert_eq!(Some(vec![2.into()]), bc.body(blocks[2]).unwrap());
|
||||
assert_eq!(Some(vec![3.into()]), bc.body(blocks[3]).unwrap());
|
||||
assert_eq!(Some(vec![4.into()]), bc.body(blocks[4]).unwrap());
|
||||
|
||||
assert_eq!(Some(vec![2.into()]), bc.body(&fork_hash_root).unwrap());
|
||||
assert_eq!(Some(vec![2.into()]), bc.body(fork_hash_root).unwrap());
|
||||
assert_eq!(bc.info().best_number, 4);
|
||||
for i in 0..5 {
|
||||
assert!(bc.hash(i).unwrap().is_some());
|
||||
@@ -3369,23 +3369,23 @@ pub(crate) mod tests {
|
||||
)
|
||||
.unwrap();
|
||||
let mut op = backend.begin_operation().unwrap();
|
||||
backend.begin_state_operation(&mut op, &blocks[4]).unwrap();
|
||||
op.mark_head(&blocks[4]).unwrap();
|
||||
backend.begin_state_operation(&mut op, blocks[4]).unwrap();
|
||||
op.mark_head(blocks[4]).unwrap();
|
||||
backend.commit_operation(op).unwrap();
|
||||
|
||||
for i in 1..5 {
|
||||
let mut op = backend.begin_operation().unwrap();
|
||||
backend.begin_state_operation(&mut op, &blocks[4]).unwrap();
|
||||
op.mark_finalized(&blocks[i], None).unwrap();
|
||||
backend.begin_state_operation(&mut op, blocks[4]).unwrap();
|
||||
op.mark_finalized(blocks[i], None).unwrap();
|
||||
backend.commit_operation(op).unwrap();
|
||||
}
|
||||
|
||||
let bc = backend.blockchain();
|
||||
assert_eq!(None, bc.body(&blocks[0]).unwrap());
|
||||
assert_eq!(None, bc.body(&blocks[1]).unwrap());
|
||||
assert_eq!(None, bc.body(&blocks[2]).unwrap());
|
||||
assert_eq!(Some(vec![3.into()]), bc.body(&blocks[3]).unwrap());
|
||||
assert_eq!(Some(vec![4.into()]), bc.body(&blocks[4]).unwrap());
|
||||
assert_eq!(None, bc.body(blocks[0]).unwrap());
|
||||
assert_eq!(None, bc.body(blocks[1]).unwrap());
|
||||
assert_eq!(None, bc.body(blocks[2]).unwrap());
|
||||
assert_eq!(Some(vec![3.into()]), bc.body(blocks[3]).unwrap());
|
||||
assert_eq!(Some(vec![4.into()]), bc.body(blocks[4]).unwrap());
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -3419,17 +3419,17 @@ pub(crate) mod tests {
|
||||
)
|
||||
.unwrap();
|
||||
let bc = backend.blockchain();
|
||||
assert_eq!(bc.indexed_transaction(&x0_hash).unwrap().unwrap(), &x0[1..]);
|
||||
assert_eq!(bc.indexed_transaction(&x1_hash).unwrap().unwrap(), &x1[1..]);
|
||||
assert_eq!(bc.indexed_transaction(x0_hash).unwrap().unwrap(), &x0[1..]);
|
||||
assert_eq!(bc.indexed_transaction(x1_hash).unwrap().unwrap(), &x1[1..]);
|
||||
|
||||
let hashof0 = bc.info().genesis_hash;
|
||||
// Push one more blocks and make sure block is pruned and transaction index is cleared.
|
||||
let block1 =
|
||||
insert_block(&backend, 1, hash, None, Default::default(), vec![], None).unwrap();
|
||||
backend.finalize_block(&block1, None).unwrap();
|
||||
assert_eq!(bc.body(&hashof0).unwrap(), None);
|
||||
assert_eq!(bc.indexed_transaction(&x0_hash).unwrap(), None);
|
||||
assert_eq!(bc.indexed_transaction(&x1_hash).unwrap(), None);
|
||||
backend.finalize_block(block1, None).unwrap();
|
||||
assert_eq!(bc.body(hashof0).unwrap(), None);
|
||||
assert_eq!(bc.indexed_transaction(x0_hash).unwrap(), None);
|
||||
assert_eq!(bc.indexed_transaction(x1_hash).unwrap(), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -3463,8 +3463,8 @@ pub(crate) mod tests {
|
||||
)
|
||||
.unwrap();
|
||||
let bc = backend.blockchain();
|
||||
assert_eq!(bc.indexed_transaction(&x0_hash).unwrap().unwrap(), &x0[..]);
|
||||
assert_eq!(bc.indexed_transaction(&x1_hash).unwrap(), None);
|
||||
assert_eq!(bc.indexed_transaction(x0_hash).unwrap().unwrap(), &x0[..]);
|
||||
assert_eq!(bc.indexed_transaction(x1_hash).unwrap(), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -3502,14 +3502,14 @@ pub(crate) mod tests {
|
||||
|
||||
for i in 1..10 {
|
||||
let mut op = backend.begin_operation().unwrap();
|
||||
backend.begin_state_operation(&mut op, &blocks[4]).unwrap();
|
||||
op.mark_finalized(&blocks[i], None).unwrap();
|
||||
backend.begin_state_operation(&mut op, blocks[4]).unwrap();
|
||||
op.mark_finalized(blocks[i], None).unwrap();
|
||||
backend.commit_operation(op).unwrap();
|
||||
let bc = backend.blockchain();
|
||||
if i < 6 {
|
||||
assert!(bc.indexed_transaction(&x1_hash).unwrap().is_some());
|
||||
assert!(bc.indexed_transaction(x1_hash).unwrap().is_some());
|
||||
} else {
|
||||
assert!(bc.indexed_transaction(&x1_hash).unwrap().is_none());
|
||||
assert!(bc.indexed_transaction(x1_hash).unwrap().is_none());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3561,31 +3561,31 @@ pub(crate) mod tests {
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(backend.blockchain().info().best_hash, best_hash);
|
||||
assert!(backend.remove_leaf_block(&best_hash).is_err());
|
||||
assert!(backend.remove_leaf_block(best_hash).is_err());
|
||||
|
||||
assert_eq!(backend.blockchain().leaves().unwrap(), vec![blocks[2], blocks[3], best_hash]);
|
||||
assert_eq!(backend.blockchain().children(blocks[1]).unwrap(), vec![blocks[2], blocks[3]]);
|
||||
|
||||
assert!(backend.have_state_at(&blocks[3], 2));
|
||||
assert!(backend.have_state_at(blocks[3], 2));
|
||||
assert!(backend.blockchain().header(BlockId::hash(blocks[3])).unwrap().is_some());
|
||||
backend.remove_leaf_block(&blocks[3]).unwrap();
|
||||
assert!(!backend.have_state_at(&blocks[3], 2));
|
||||
backend.remove_leaf_block(blocks[3]).unwrap();
|
||||
assert!(!backend.have_state_at(blocks[3], 2));
|
||||
assert!(backend.blockchain().header(BlockId::hash(blocks[3])).unwrap().is_none());
|
||||
assert_eq!(backend.blockchain().leaves().unwrap(), vec![blocks[2], best_hash]);
|
||||
assert_eq!(backend.blockchain().children(blocks[1]).unwrap(), vec![blocks[2]]);
|
||||
|
||||
assert!(backend.have_state_at(&blocks[2], 2));
|
||||
assert!(backend.have_state_at(blocks[2], 2));
|
||||
assert!(backend.blockchain().header(BlockId::hash(blocks[2])).unwrap().is_some());
|
||||
backend.remove_leaf_block(&blocks[2]).unwrap();
|
||||
assert!(!backend.have_state_at(&blocks[2], 2));
|
||||
backend.remove_leaf_block(blocks[2]).unwrap();
|
||||
assert!(!backend.have_state_at(blocks[2], 2));
|
||||
assert!(backend.blockchain().header(BlockId::hash(blocks[2])).unwrap().is_none());
|
||||
assert_eq!(backend.blockchain().leaves().unwrap(), vec![best_hash, blocks[1]]);
|
||||
assert_eq!(backend.blockchain().children(blocks[1]).unwrap(), vec![]);
|
||||
|
||||
assert!(backend.have_state_at(&blocks[1], 1));
|
||||
assert!(backend.have_state_at(blocks[1], 1));
|
||||
assert!(backend.blockchain().header(BlockId::hash(blocks[1])).unwrap().is_some());
|
||||
backend.remove_leaf_block(&blocks[1]).unwrap();
|
||||
assert!(!backend.have_state_at(&blocks[1], 1));
|
||||
backend.remove_leaf_block(blocks[1]).unwrap();
|
||||
assert!(!backend.have_state_at(blocks[1], 1));
|
||||
assert!(backend.blockchain().header(BlockId::hash(blocks[1])).unwrap().is_none());
|
||||
assert_eq!(backend.blockchain().leaves().unwrap(), vec![best_hash]);
|
||||
assert_eq!(backend.blockchain().children(blocks[0]).unwrap(), vec![best_hash]);
|
||||
@@ -3678,7 +3678,7 @@ pub(crate) mod tests {
|
||||
|
||||
let block1_a = insert_header(&backend, 1, block0, None, Default::default());
|
||||
let block2_a = insert_header(&backend, 2, block1_a, None, Default::default());
|
||||
backend.finalize_block(&block1_a, None).unwrap();
|
||||
backend.finalize_block(block1_a, None).unwrap();
|
||||
assert_eq!(backend.blockchain().leaves().unwrap(), vec![block2_a]);
|
||||
|
||||
// Insert a fork prior to finalization point. Leave should not be created.
|
||||
@@ -3702,7 +3702,7 @@ pub(crate) mod tests {
|
||||
|
||||
let block3 = {
|
||||
let mut op = backend.begin_operation().unwrap();
|
||||
backend.begin_state_operation(&mut op, &block1).unwrap();
|
||||
backend.begin_state_operation(&mut op, block1).unwrap();
|
||||
let header = Header {
|
||||
number: 3,
|
||||
parent_hash: block2,
|
||||
@@ -3721,7 +3721,7 @@ pub(crate) mod tests {
|
||||
|
||||
let block4 = {
|
||||
let mut op = backend.begin_operation().unwrap();
|
||||
backend.begin_state_operation(&mut op, &block2).unwrap();
|
||||
backend.begin_state_operation(&mut op, block2).unwrap();
|
||||
let header = Header {
|
||||
number: 4,
|
||||
parent_hash: block3,
|
||||
@@ -3740,7 +3740,7 @@ pub(crate) mod tests {
|
||||
|
||||
let block3_fork = {
|
||||
let mut op = backend.begin_operation().unwrap();
|
||||
backend.begin_state_operation(&mut op, &block2).unwrap();
|
||||
backend.begin_state_operation(&mut op, block2).unwrap();
|
||||
let header = Header {
|
||||
number: 3,
|
||||
parent_hash: block2,
|
||||
@@ -3757,22 +3757,22 @@ pub(crate) mod tests {
|
||||
header.hash()
|
||||
};
|
||||
|
||||
assert!(backend.have_state_at(&block1, 1));
|
||||
assert!(backend.have_state_at(&block2, 2));
|
||||
assert!(backend.have_state_at(&block3, 3));
|
||||
assert!(backend.have_state_at(&block4, 4));
|
||||
assert!(backend.have_state_at(&block3_fork, 3));
|
||||
assert!(backend.have_state_at(block1, 1));
|
||||
assert!(backend.have_state_at(block2, 2));
|
||||
assert!(backend.have_state_at(block3, 3));
|
||||
assert!(backend.have_state_at(block4, 4));
|
||||
assert!(backend.have_state_at(block3_fork, 3));
|
||||
|
||||
assert_eq!(backend.blockchain.leaves().unwrap(), vec![block4, block3_fork]);
|
||||
assert_eq!(4, backend.blockchain.leaves.read().highest_leaf().unwrap().0);
|
||||
|
||||
assert_eq!(3, backend.revert(1, false).unwrap().0);
|
||||
|
||||
assert!(backend.have_state_at(&block1, 1));
|
||||
assert!(!backend.have_state_at(&block2, 2));
|
||||
assert!(!backend.have_state_at(&block3, 3));
|
||||
assert!(!backend.have_state_at(&block4, 4));
|
||||
assert!(!backend.have_state_at(&block3_fork, 3));
|
||||
assert!(backend.have_state_at(block1, 1));
|
||||
assert!(!backend.have_state_at(block2, 2));
|
||||
assert!(!backend.have_state_at(block3, 3));
|
||||
assert!(!backend.have_state_at(block4, 4));
|
||||
assert!(!backend.have_state_at(block3_fork, 3));
|
||||
|
||||
assert_eq!(backend.blockchain.leaves().unwrap(), vec![block1]);
|
||||
assert_eq!(1, backend.blockchain.leaves.read().highest_leaf().unwrap().0);
|
||||
|
||||
Reference in New Issue
Block a user