mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 12:17:58 +00:00
Fix tx-pool returning the same transaction multiple times (#6535)
* Fix tx-pool returning the same transaction multiple times This fixes a bug that lead to returning the same transaction multiple times when iterating the `ready` iterator. Internally the transaction was kept in the `best` list and could be duplicated in that list be re-inserting it again. This `best` list is using a `TransactionRef` which internally uses a `insertion_id`. This `insertion_id` could lead to the same transaction being inserted multiple times into the `best` list. * Update client/transaction-pool/src/testing/pool.rs Co-authored-by: Nikolay Volf <nikvolf@gmail.com> Co-authored-by: Nikolay Volf <nikvolf@gmail.com>
This commit is contained in:
@@ -194,10 +194,20 @@ impl sp_runtime::traits::Dispatchable for Extrinsic {
|
||||
}
|
||||
|
||||
impl Extrinsic {
|
||||
/// Convert `&self` into `&Transfer`.
|
||||
///
|
||||
/// Panics if this is no `Transfer` extrinsic.
|
||||
pub fn transfer(&self) -> &Transfer {
|
||||
self.try_transfer().expect("cannot convert to transfer ref")
|
||||
}
|
||||
|
||||
/// Try to convert `&self` into `&Transfer`.
|
||||
///
|
||||
/// Returns `None` if this is no `Transfer` extrinsic.
|
||||
pub fn try_transfer(&self) -> Option<&Transfer> {
|
||||
match self {
|
||||
Extrinsic::Transfer { ref transfer, .. } => transfer,
|
||||
_ => panic!("cannot convert to transfer ref"),
|
||||
Extrinsic::Transfer { ref transfer, .. } => Some(transfer),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user