mempool: use capacity parameter to avoid map reallocations

Which is what happens in AddBlock that fills a new pool with exactly the
number of transactions we know already.
This commit is contained in:
Roman Khimov 2021-11-30 19:19:43 +03:00
parent e236ac4067
commit 428ba48444

View file

@ -422,7 +422,7 @@ func (mp *Pool) checkPolicy(tx *transaction.Transaction, policyChanged bool) boo
// New returns a new Pool struct.
func New(capacity int, payerIndex int, enableSubscriptions bool) *Pool {
mp := &Pool{
verifiedMap: make(map[util.Uint256]*transaction.Transaction),
verifiedMap: make(map[util.Uint256]*transaction.Transaction, capacity),
verifiedTxes: make([]item, 0, capacity),
capacity: capacity,
payerIndex: payerIndex,