mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 22:11:06 +00:00
Refactored in-mem backed to use the actual trie (#5730)
This commit is contained in:
@@ -464,7 +464,7 @@ pub struct BlockImportOperation<Block: BlockT> {
|
||||
pending_block: Option<PendingBlock<Block>>,
|
||||
pending_cache: HashMap<CacheKeyId, Vec<u8>>,
|
||||
old_state: InMemoryBackend<HashFor<Block>>,
|
||||
new_state: Option<InMemoryBackend<HashFor<Block>>>,
|
||||
new_state: Option<<InMemoryBackend<HashFor<Block>> as StateBackend<HashFor<Block>>>::Transaction>,
|
||||
aux: Vec<(Vec<u8>, Option<Vec<u8>>)>,
|
||||
finalized_blocks: Vec<(BlockId<Block>, Option<Justification>)>,
|
||||
set_head: Option<BlockId<Block>>,
|
||||
@@ -502,7 +502,7 @@ impl<Block: BlockT> backend::BlockImportOperation<Block> for BlockImportOperatio
|
||||
&mut self,
|
||||
update: <InMemoryBackend<HashFor<Block>> as StateBackend<HashFor<Block>>>::Transaction,
|
||||
) -> sp_blockchain::Result<()> {
|
||||
self.new_state = Some(self.old_state.update(update));
|
||||
self.new_state = Some(update);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -525,7 +525,7 @@ impl<Block: BlockT> backend::BlockImportOperation<Block> for BlockImportOperatio
|
||||
child_delta
|
||||
);
|
||||
|
||||
self.new_state = Some(InMemoryBackend::from(transaction));
|
||||
self.new_state = Some(transaction);
|
||||
Ok(root)
|
||||
}
|
||||
|
||||
@@ -638,7 +638,12 @@ impl<Block: BlockT> backend::Backend<Block> for Backend<Block> where Block::Hash
|
||||
|
||||
let hash = header.hash();
|
||||
|
||||
self.states.write().insert(hash, operation.new_state.unwrap_or_else(|| old_state.clone()));
|
||||
let new_state = match operation.new_state {
|
||||
Some(state) => old_state.update_backend(*header.state_root(), state),
|
||||
None => old_state.clone(),
|
||||
};
|
||||
|
||||
self.states.write().insert(hash, new_state);
|
||||
|
||||
self.blockchain.insert(hash, header, justification, body, pending_block.state)?;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user