Closed GoodKlaus closed 5 months ago
insert
transaction nonce check.insert
if the mempool is too full to accept the new transaction.Filter
a generic type parameter or an associated type. (e.g., Mempool<F>
). This allows us to change the filtering functionality of the mempool in the future without changing much of the type's basic insert and pop logic.pchain-mempool
crate.RwLock
over mempool and frequently read locking to read its size may crowd out threads that need a write lock to use the mempool (e.g., the insertion thread and the executor).
Mempool Design Report
1. Requirements
2. Mempool
2.1 new() method
Algorithm Pseudocode
2.2 insert() method
Algorithm Pseudocode
Complexity Alalysis
contains_key(), get() and insert()
, and N is the number of transaction of the specific signer. The Priority queue data structure introduces O(logM) complexity forchange_priority() and push()
, and M is the number of signers.Space Complexity O(N) It is arrived mainly based on the Mempool data structure, and no auxiliary space is used for this method. N is the number of transactions.
2.3 pop() method
Algorithm Pseudocode
Complexity Analysis
pop()
, and N is the number of transaction of the specific signer. The Priority queue data structure introduces O(MlogM) complexity for looping through “self.ranked_accounts_fee”, and N is the number of the signers. However, the average time complexity is better than transforming the priority queue into sorted vector directly.3. NonceStore
3.1 get() method
Algorithm Pseudocode
4. Removing Stuck Transactions
4.1 Process
produce block time limit
window, check mempool sizempsc channel
4.2 Algorithm Pseudocode
5. Mempool Read Access Handling
5.1 Description
5.2 Handling