mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-18 19:00:46 +00:00
replace TRC21Cost with TxCost
This commit is contained in:
parent
9a7ffaa09f
commit
0e8b3f1d31
3 changed files with 15 additions and 8 deletions
|
|
@ -290,7 +290,7 @@ func (l *txList) Forward(threshold uint64) types.Transactions {
|
||||||
// a point in calculating all the costs or if the balance covers all. If the threshold
|
// a point in calculating all the costs or if the balance covers all. If the threshold
|
||||||
// is lower than the costgas cap, the caps will be reset to a new high after removing
|
// is lower than the costgas cap, the caps will be reset to a new high after removing
|
||||||
// the newly invalidated transactions.
|
// the newly invalidated transactions.
|
||||||
func (l *txList) Filter(costLimit *big.Int, gasLimit uint64, trc21Issuers map[common.Address]*big.Int) (types.Transactions, types.Transactions) {
|
func (l *txList) Filter(costLimit *big.Int, gasLimit uint64, trc21Issuers map[common.Address]*big.Int, number *big.Int) (types.Transactions, types.Transactions) {
|
||||||
// If all transactions are below the threshold, short circuit
|
// If all transactions are below the threshold, short circuit
|
||||||
if l.costcap.Cmp(costLimit) <= 0 && l.gascap <= gasLimit {
|
if l.costcap.Cmp(costLimit) <= 0 && l.gascap <= gasLimit {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
|
|
@ -303,7 +303,7 @@ func (l *txList) Filter(costLimit *big.Int, gasLimit uint64, trc21Issuers map[co
|
||||||
maximum := costLimit
|
maximum := costLimit
|
||||||
if tx.To() != nil {
|
if tx.To() != nil {
|
||||||
if feeCapacity, ok := trc21Issuers[*tx.To()]; ok {
|
if feeCapacity, ok := trc21Issuers[*tx.To()]; ok {
|
||||||
return new(big.Int).Add(costLimit, feeCapacity).Cmp(tx.TRC21Cost()) < 0 || tx.Gas() > gasLimit
|
return new(big.Int).Add(costLimit, feeCapacity).Cmp(tx.TxCost(number)) < 0 || tx.Gas() > gasLimit
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return tx.Cost().Cmp(maximum) > 0 || tx.Gas() > gasLimit
|
return tx.Cost().Cmp(maximum) > 0 || tx.Gas() > gasLimit
|
||||||
|
|
|
||||||
|
|
@ -645,8 +645,7 @@ func (pool *TxPool) validateTx(tx *types.Transaction, local bool) error {
|
||||||
if !state.ValidateTRC21Tx(pool.pendingState.StateDB, from, *tx.To(), tx.Data()) {
|
if !state.ValidateTRC21Tx(pool.pendingState.StateDB, from, *tx.To(), tx.Data()) {
|
||||||
return ErrInsufficientFunds
|
return ErrInsufficientFunds
|
||||||
}
|
}
|
||||||
cost = tx.TRC21Cost()
|
cost = tx.TxCost(number)
|
||||||
minGasPrice = common.TRC21GasPrice
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if new(big.Int).Add(balance, feeCapacity).Cmp(cost) < 0 {
|
if new(big.Int).Add(balance, feeCapacity).Cmp(cost) < 0 {
|
||||||
|
|
@ -1070,7 +1069,11 @@ func (pool *TxPool) promoteExecutables(accounts []common.Address) {
|
||||||
pool.priced.Removed()
|
pool.priced.Removed()
|
||||||
}
|
}
|
||||||
// Drop all transactions that are too costly (low balance or out of gas)
|
// Drop all transactions that are too costly (low balance or out of gas)
|
||||||
drops, _ := list.Filter(pool.currentState.GetBalance(addr), pool.currentMaxGas, pool.trc21FeeCapacity)
|
var number *big.Int = nil
|
||||||
|
if pool.chain.CurrentHeader() != nil {
|
||||||
|
number = pool.chain.CurrentHeader().Number
|
||||||
|
}
|
||||||
|
drops, _ := list.Filter(pool.currentState.GetBalance(addr), pool.currentMaxGas, pool.trc21FeeCapacity, number)
|
||||||
for _, tx := range drops {
|
for _, tx := range drops {
|
||||||
hash := tx.Hash()
|
hash := tx.Hash()
|
||||||
log.Trace("Removed unpayable queued transaction", "hash", hash)
|
log.Trace("Removed unpayable queued transaction", "hash", hash)
|
||||||
|
|
@ -1228,7 +1231,11 @@ func (pool *TxPool) demoteUnexecutables() {
|
||||||
pool.priced.Removed()
|
pool.priced.Removed()
|
||||||
}
|
}
|
||||||
// Drop all transactions that are too costly (low balance or out of gas), and queue any invalids back for later
|
// Drop all transactions that are too costly (low balance or out of gas), and queue any invalids back for later
|
||||||
drops, invalids := list.Filter(pool.currentState.GetBalance(addr), pool.currentMaxGas, pool.trc21FeeCapacity)
|
var number *big.Int = nil
|
||||||
|
if pool.chain.CurrentHeader() != nil {
|
||||||
|
number = pool.chain.CurrentHeader().Number
|
||||||
|
}
|
||||||
|
drops, invalids := list.Filter(pool.currentState.GetBalance(addr), pool.currentMaxGas, pool.trc21FeeCapacity, number)
|
||||||
for _, tx := range drops {
|
for _, tx := range drops {
|
||||||
hash := tx.Hash()
|
hash := tx.Hash()
|
||||||
log.Trace("Removed unpayable pending transaction", "hash", hash)
|
log.Trace("Removed unpayable pending transaction", "hash", hash)
|
||||||
|
|
|
||||||
|
|
@ -293,8 +293,8 @@ func (tx *Transaction) Cost() *big.Int {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cost returns amount + gasprice * gaslimit.
|
// Cost returns amount + gasprice * gaslimit.
|
||||||
func (tx *Transaction) TRC21Cost() *big.Int {
|
func (tx *Transaction) TxCost(number *big.Int) *big.Int {
|
||||||
total := new(big.Int).Mul(common.TRC21GasPrice, new(big.Int).SetUint64(tx.data.GasLimit))
|
total := new(big.Int).Mul(common.GetGasPrice(number), new(big.Int).SetUint64(tx.data.GasLimit))
|
||||||
total.Add(total, tx.data.Amount)
|
total.Add(total, tx.data.Amount)
|
||||||
return total
|
return total
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue