core/types: rename to calcEffectiveGasTip

This commit is contained in:
lightclient 2025-05-05 15:59:42 -06:00
parent 1a1c1a4718
commit 8d6ca2e5ba
No known key found for this signature in database
GPG key ID: 657913021EF45A6A
2 changed files with 11 additions and 9 deletions

View file

@ -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)
}

View file

@ -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) {