Skip to content

Commit 1d3b904

Browse files
authored
Merge pull request #4489 from anoma/grarco/sorted-tx-results
Sorted tx results in events
2 parents 00efc0c + ec0ab2f commit 1d3b904

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- The orderd of results of the inner transactions of a batch is now preserved in
2+
the events. ([\#4489](https://github.com/anoma/namada/pull/4489))

crates/tx/src/data/mod.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pub mod protocol;
1111
pub mod wrapper;
1212

1313
use std::borrow::Cow;
14-
use std::collections::{BTreeMap, BTreeSet};
14+
use std::collections::BTreeSet;
1515
use std::fmt::{self, Display};
1616
use std::marker::PhantomData;
1717
use std::str::FromStr;
@@ -22,6 +22,7 @@ use namada_core::address::Address;
2222
use namada_core::borsh::{
2323
BorshDeserialize, BorshSchema, BorshSerialize, BorshSerializeExt,
2424
};
25+
use namada_core::collections::HashMap;
2526
use namada_core::hash::Hash;
2627
use namada_core::storage;
2728
use namada_events::Event;
@@ -227,7 +228,7 @@ pub struct DryRunResult(pub TxResult<String>, pub WholeGas);
227228
// strings
228229
// TODO derive BorshSchema after <https://github.com/near/borsh-rs/issues/82>
229230
#[derive(Clone, Debug, BorshSerialize, BorshDeserialize)]
230-
pub struct TxResult<T>(pub BTreeMap<Hash, Result<BatchedTxResult, T>>);
231+
pub struct TxResult<T>(pub HashMap<Hash, Result<BatchedTxResult, T>>);
231232

232233
impl<T> Default for TxResult<T> {
233234
fn default() -> Self {
@@ -300,8 +301,8 @@ impl<'de, T: Deserialize<'de>> serde::Deserialize<'de> for TxResult<T> {
300301
impl<T: Display> TxResult<T> {
301302
/// Convert the batched result to a string
302303
pub fn to_result_string(self) -> TxResult<String> {
303-
let mut batch_results: BTreeMap<Hash, Result<BatchedTxResult, String>> =
304-
BTreeMap::new();
304+
let mut batch_results: HashMap<Hash, Result<BatchedTxResult, String>> =
305+
HashMap::new();
305306

306307
for (hash, res) in self.0 {
307308
let res = match res {
@@ -317,8 +318,8 @@ impl<T: Display> TxResult<T> {
317318

318319
impl<T> TxResult<T> {
319320
/// Return a new set of tx results.
320-
pub const fn new() -> Self {
321-
Self(BTreeMap::new())
321+
pub fn new() -> Self {
322+
Self(HashMap::new())
322323
}
323324

324325
/// Insert an inner tx result into this [`TxResult`].

0 commit comments

Comments
 (0)