mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-12-13 05:45:02 +00:00
Merge pull request #1022 from nspcc-dev/fix-maxfreetxperblock-neox-2.x
core: respect MaxFreeTransactionsPerBlock setting
This commit is contained in:
commit
349d8a1984
1 changed files with 6 additions and 5 deletions
|
@ -1528,12 +1528,13 @@ func (bc *Blockchain) ApplyPolicyToTxSet(txes []mempool.TxWithFee) []mempool.TxW
|
||||||
txes = txes[:bc.config.MaxTransactionsPerBlock]
|
txes = txes[:bc.config.MaxTransactionsPerBlock]
|
||||||
}
|
}
|
||||||
maxFree := bc.config.MaxFreeTransactionsPerBlock
|
maxFree := bc.config.MaxFreeTransactionsPerBlock
|
||||||
if maxFree != 0 {
|
if maxFree != 0 && len(txes) > maxFree {
|
||||||
lowStart := sort.Search(len(txes), func(i int) bool {
|
// Transactions are sorted by fee, so we just find the first free one.
|
||||||
return bc.IsLowPriority(txes[i].Fee)
|
freeStart := sort.Search(len(txes), func(i int) bool {
|
||||||
|
return txes[i].Fee == 0
|
||||||
})
|
})
|
||||||
if lowStart+maxFree < len(txes) {
|
if freeStart+maxFree < len(txes) {
|
||||||
txes = txes[:lowStart+maxFree]
|
txes = txes[:freeStart+maxFree]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return txes
|
return txes
|
||||||
|
|
Loading…
Reference in a new issue