From 9c94f65253cb1d1e501afffd30232d619067cfd7 Mon Sep 17 00:00:00 2001 From: Maksym Hrynenko Date: Wed, 8 May 2024 19:32:44 +0300 Subject: [PATCH] update: move gasPrice multiplier near the gas limit for better clarifying --- internal/service/api/handlers/register.go | 3 +-- internal/service/api/handlers/transit_state.go | 3 +-- internal/service/api/handlers/vote.go | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/internal/service/api/handlers/register.go b/internal/service/api/handlers/register.go index 4b5e5e5..a1c3930 100644 --- a/internal/service/api/handlers/register.go +++ b/internal/service/api/handlers/register.go @@ -83,7 +83,6 @@ func Register(w http.ResponseWriter, r *http.Request) { ape.RenderErr(w, problems.InternalError()) return } - gasPrice = multiplyGasPrice(gasPrice, NetworkConfig(r).GasMultiplier) NetworkConfig(r).LockNonce() defer NetworkConfig(r).UnlockNonce() @@ -106,7 +105,7 @@ func Register(w http.ResponseWriter, r *http.Request) { &types.LegacyTx{ Nonce: NetworkConfig(r).Nonce(), Gas: uint64(float64(gas) * NetworkConfig(r).GasMultiplier), - GasPrice: gasPrice, + GasPrice: multiplyGasPrice(gasPrice, NetworkConfig(r).GasMultiplier), To: ®istration, Data: dataBytes, }, diff --git a/internal/service/api/handlers/transit_state.go b/internal/service/api/handlers/transit_state.go index 6cee475..84269ca 100644 --- a/internal/service/api/handlers/transit_state.go +++ b/internal/service/api/handlers/transit_state.go @@ -105,7 +105,6 @@ func getTxOpts(r *http.Request, receiver common.Address, txData []byte) (*bind.T if err != nil { return nil, errors.Wrap(err, "failed to suggest gas price") } - gasPrice = multiplyGasPrice(gasPrice, NetworkConfig(r).GasMultiplier) gasLimit, err := EthClient(r).EstimateGas(r.Context(), ethereum.CallMsg{ From: crypto.PubkeyToAddress(NetworkConfig(r).PrivateKey.PublicKey), @@ -123,7 +122,7 @@ func getTxOpts(r *http.Request, receiver common.Address, txData []byte) (*bind.T } txOpts.Nonce = new(big.Int).SetUint64(NetworkConfig(r).Nonce()) - txOpts.GasPrice = gasPrice + txOpts.GasPrice = multiplyGasPrice(gasPrice, NetworkConfig(r).GasMultiplier) txOpts.GasLimit = uint64(float64(gasLimit) * NetworkConfig(r).GasMultiplier) return txOpts, nil diff --git a/internal/service/api/handlers/vote.go b/internal/service/api/handlers/vote.go index e6b4989..e27d9b8 100644 --- a/internal/service/api/handlers/vote.go +++ b/internal/service/api/handlers/vote.go @@ -54,7 +54,6 @@ func Vote(w http.ResponseWriter, r *http.Request) { ape.RenderErr(w, problems.InternalError()) return } - gasPrice = multiplyGasPrice(gasPrice, NetworkConfig(r).GasMultiplier) NetworkConfig(r).LockNonce() defer NetworkConfig(r).UnlockNonce() @@ -77,7 +76,7 @@ func Vote(w http.ResponseWriter, r *http.Request) { &types.LegacyTx{ Nonce: NetworkConfig(r).Nonce(), Gas: uint64(float64(gas) * NetworkConfig(r).GasMultiplier), - GasPrice: gasPrice, + GasPrice: multiplyGasPrice(gasPrice, NetworkConfig(r).GasMultiplier), To: &voting, Data: dataBytes, },