Feature and its Use Cases
Area of improvement :
Every call to add_transaction() iterates the entire _list to detect duplicate transactions and nonce conflicts. The current version of add_transaction() utilizes a loop serves two purposes :
1] Duplicate / RBF detection - find an existing tx with the same (sender, nonce).
2] Nonce-ordering window - compute i_min / i_max so the new tx is inserted in the right position relative to other nonces from the same sender.
Proposed Fix : Both can be answered in sub-linear time with a side index.
Add a dict keyed by (sender, nonce) maintained alongside _list:
self._index: dict[tuple, object] = {}
The index is kept in sync in three places:
insert (self._index[key] = tx)
replace / RBF (del self._index[key] before removing from list, then re-add)
eviction (self._index.pop(key, None) inside remove_transactions)
Additional Context
No response
Code of Conduct
Feature and its Use Cases
Area of improvement :
Every call to add_transaction() iterates the entire _list to detect duplicate transactions and nonce conflicts. The current version of add_transaction() utilizes a loop serves two purposes :
1] Duplicate / RBF detection - find an existing tx with the same (sender, nonce).
2] Nonce-ordering window - compute i_min / i_max so the new tx is inserted in the right position relative to other nonces from the same sender.
Proposed Fix : Both can be answered in sub-linear time with a side index.
Add a dict keyed by (sender, nonce) maintained alongside _list:
self._index: dict[tuple, object] = {}
The index is kept in sync in three places:
insert (self._index[key] = tx)
replace / RBF (del self._index[key] before removing from list, then re-add)
eviction (self._index.pop(key, None) inside remove_transactions)
Additional Context
No response
Code of Conduct