mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 23:26:44 +00:00
feat(miner): improve pruneTransactions (#411)
This commit is contained in:
parent
682235849b
commit
7a019ea44b
1 changed files with 10 additions and 11 deletions
|
|
@ -391,9 +391,14 @@ func pruneTransactions(
|
||||||
var (
|
var (
|
||||||
prunedTxs []*types.Transaction
|
prunedTxs []*types.Transaction
|
||||||
prunedReceipts []*types.Receipt
|
prunedReceipts []*types.Receipt
|
||||||
|
step = TxListCompressionPruneStep
|
||||||
)
|
)
|
||||||
|
|
||||||
for len(txs) > 0 {
|
for len(txs) > 0 {
|
||||||
|
if len(txs) <= step {
|
||||||
|
step = 1
|
||||||
|
}
|
||||||
|
|
||||||
b, err := encodeAndCompressTxList(txs)
|
b, err := encodeAndCompressTxList(txs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
@ -406,17 +411,11 @@ func pruneTransactions(
|
||||||
Size: len(b),
|
Size: len(b),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
if len(txs) < TxListCompressionPruneStep {
|
|
||||||
prunedTxs = append(txs, prunedTxs...)
|
prunedTxs = append(txs[len(txs)-step:], prunedTxs...)
|
||||||
prunedReceipts = append(receipts, prunedReceipts...)
|
prunedReceipts = append(receipts[len(receipts)-step:], prunedReceipts...)
|
||||||
txs = []*types.Transaction{}
|
txs = txs[:len(txs)-step]
|
||||||
receipts = []*types.Receipt{}
|
receipts = receipts[:len(receipts)-step]
|
||||||
break
|
|
||||||
}
|
|
||||||
prunedTxs = append(txs[len(txs)-TxListCompressionPruneStep:], prunedTxs...)
|
|
||||||
prunedReceipts = append(receipts[len(receipts)-TxListCompressionPruneStep:], prunedReceipts...)
|
|
||||||
txs = txs[:len(txs)-TxListCompressionPruneStep]
|
|
||||||
receipts = receipts[:len(receipts)-TxListCompressionPruneStep]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// All transactions are pruned.
|
// All transactions are pruned.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue