0

How do I remove duplications of transactions from the transaction pool? I noticed some return a tag in a signed SignedExtension TransactionValidity provides field. However, it is not clear to me how this works.

2 Answers 2

1

Basically, the transaction pool deduplicates the transactions using provides tags. Right now, if you provide two equal values for different transactions, only one will be admitted to the tx pool and later included in the block. Let's say you have the following code for validating a transaction:

ValidTransaction::with_tag_prefix("MyPallet")
                        .priority(TransactionPriority::MAX)
                        .longevity(10)
                        .propagate(true)
                        .and_provides(value_1)
                        .and_provides(value_2)
                        .build()

Now, if you have two transactions with an overlap in EITHER value_1 or value_2, one of the transactions will be dropped. That's how the transaction pool deduplicates transactions.

2

What's your definition of the duplication.

Here is an example. As you can see there's a matcher to analyze the call struct.

Then you could do something like this:

Some(Call::set_dummy { maybe_a_hash, .. }) {
    if xxx.contains(maybe_a_hash) {
        return InvalidTransaction::Custom(<Error<T>>::AlreadyExisted.as_u8()).into()
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.