mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 21:37:56 +00:00
ProofRecorder: Implement transactional support (#13769)
* TrieRecorder: Start adding support for transactions * Adds `transactions` functions and some test * More tests * Docs * Ensure that we rollback failed transactions in the storage proof * FMT * Update primitives/trie/src/recorder.rs Co-authored-by: Dmitry Markin <dmitry@markin.tech> * Review comments * Update primitives/trie/src/recorder.rs Co-authored-by: Sebastian Kunert <skunert49@gmail.com> * ".git/.scripts/commands/fmt/fmt.sh" * For the holy clippy! * Update primitives/trie/src/recorder.rs Co-authored-by: Anton <anton.kalyaev@gmail.com> --------- Co-authored-by: Dmitry Markin <dmitry@markin.tech> Co-authored-by: Sebastian Kunert <skunert49@gmail.com> Co-authored-by: command-bot <> Co-authored-by: Anton <anton.kalyaev@gmail.com>
This commit is contained in:
@@ -275,6 +275,32 @@ fn execute_transaction_backend(utx: &Extrinsic, extrinsic_index: u32) -> ApplyEx
|
||||
Ok(Ok(()))
|
||||
},
|
||||
Extrinsic::Store(data) => execute_store(data.clone()),
|
||||
Extrinsic::ReadAndPanic(i) => execute_read(*i, true),
|
||||
Extrinsic::Read(i) => execute_read(*i, false),
|
||||
}
|
||||
}
|
||||
|
||||
fn execute_read(read: u32, panic_at_end: bool) -> ApplyExtrinsicResult {
|
||||
let mut next_key = vec![];
|
||||
for _ in 0..(read as usize) {
|
||||
if let Some(next) = sp_io::storage::next_key(&next_key) {
|
||||
// Read the value
|
||||
sp_io::storage::get(&next);
|
||||
|
||||
next_key = next;
|
||||
} else {
|
||||
if panic_at_end {
|
||||
return Ok(Ok(()))
|
||||
} else {
|
||||
panic!("Could not read {read} times from the state");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if panic_at_end {
|
||||
panic!("BYE")
|
||||
} else {
|
||||
Ok(Ok(()))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user