mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 06:36:43 +00:00
core/types: rename to calcEffectiveGasTip
This commit is contained in:
parent
1a1c1a4718
commit
8d6ca2e5ba
2 changed files with 11 additions and 9 deletions
|
|
@ -356,11 +356,13 @@ func (tx *Transaction) GasTipCapIntCmp(other *big.Int) int {
|
|||
// the actual negative value, _and_ ErrGasFeeCapTooLow
|
||||
func (tx *Transaction) EffectiveGasTip(baseFee *big.Int) (*big.Int, error) {
|
||||
dst := new(big.Int)
|
||||
err := tx.effectiveGasTipInto(dst, baseFee)
|
||||
err := tx.calcEffectiveGasTip(dst, baseFee)
|
||||
return dst, err
|
||||
}
|
||||
|
||||
func (tx *Transaction) effectiveGasTipInto(dst *big.Int, baseFee *big.Int) error {
|
||||
// calcEffectiveGasTip calculates the effective gas tip of the transaction and
|
||||
// saves the result to dst.
|
||||
func (tx *Transaction) calcEffectiveGasTip(dst *big.Int, baseFee *big.Int) error {
|
||||
if baseFee == nil {
|
||||
dst.Set(tx.inner.gasTipCap())
|
||||
return nil
|
||||
|
|
@ -385,10 +387,10 @@ func (tx *Transaction) EffectiveGasTipCmp(other *Transaction, baseFee *big.Int)
|
|||
if baseFee == nil {
|
||||
return tx.GasTipCapCmp(other)
|
||||
}
|
||||
txTip := new(big.Int)
|
||||
otherTip := new(big.Int)
|
||||
tx.effectiveGasTipInto(txTip, baseFee)
|
||||
other.effectiveGasTipInto(otherTip, baseFee)
|
||||
// Use more efficient internal method.
|
||||
txTip, otherTip := new(big.Int), new(big.Int)
|
||||
tx.calcEffectiveGasTip(txTip, baseFee)
|
||||
other.calcEffectiveGasTip(otherTip, baseFee)
|
||||
return txTip.Cmp(otherTip)
|
||||
}
|
||||
|
||||
|
|
@ -398,7 +400,7 @@ func (tx *Transaction) EffectiveGasTipIntCmp(other *big.Int, baseFee *big.Int) i
|
|||
return tx.GasTipCapIntCmp(other)
|
||||
}
|
||||
txTip := new(big.Int)
|
||||
tx.effectiveGasTipInto(txTip, baseFee)
|
||||
tx.calcEffectiveGasTip(txTip, baseFee)
|
||||
return txTip.Cmp(other)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -625,7 +625,7 @@ func BenchmarkEffectiveGasTip(b *testing.B) {
|
|||
b.ReportAllocs()
|
||||
dst := new(big.Int)
|
||||
for i := 0; i < b.N; i++ {
|
||||
err := tx.effectiveGasTipInto(dst, baseFee)
|
||||
err := tx.calcEffectiveGasTip(dst, baseFee)
|
||||
if err != nil {
|
||||
b.Fatal(err)
|
||||
}
|
||||
|
|
@ -675,7 +675,7 @@ func TestEffectiveGasTipInto(t *testing.T) {
|
|||
|
||||
// Get result from new method
|
||||
dst := new(big.Int)
|
||||
newErr := tx.effectiveGasTipInto(dst, baseFee)
|
||||
newErr := tx.calcEffectiveGasTip(dst, baseFee)
|
||||
|
||||
// Compare results
|
||||
if (origErr != nil) != (newErr != nil) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue