mempool: don't sort items by hash

There is nothing requiring us to do so. It also is bad because it allows for
new transaction to replace some already existing one with the same fee
parameters just because it has "better" hash.

But the other thing is that for transactions with equal fees it's always
better for us to append them to the end of the list, instead of inserting them
in the middle, so this change allows to reduce slice item movements and gain
some 6-7% increase for single-node TPS.
This commit is contained in:
Roman Khimov 2020-08-30 14:46:42 +03:00
parent 5df726db68
commit 9591d64e53

View file

@ -76,12 +76,7 @@ func (p item) CompareTo(otherP item) int {
return ret
}
if ret := int(p.txn.NetworkFee - otherP.txn.NetworkFee); ret != 0 {
return ret
}
// Transaction hash sorted descending.
return otherP.txn.Hash().CompareTo(p.txn.Hash())
return int(p.txn.NetworkFee - otherP.txn.NetworkFee)
}
// Count returns the total number of uncofirm transactions.