Browse Source

fix EIP1559 support: set maxPriorityFee in config

master
yuriy0803 3 years ago
parent
commit
d58dd2e295
  1. 3
      api.json
  2. 8
      payouts/payer.go
  3. 7
      rpc/rpc.go

3
api.json

@ -120,9 +120,10 @@
"interval": "20m",
"daemon": "http://127.0.0.1:8545",
"timeout": "10s",
"address": "0x9dd0226060b6d9644066029f4993CB2A40cF775D",
"address": "0xd92fa5a9732a0aec36dc8d5a6a1305dc2d3e09e6",
"gas": "21000",
"gasPrice": "50000000000",
"maxPriorityFee": "2000000000",
"autoGas": true,
"threshold": 500000000,
"bgsave": false,

8
payouts/payer.go

@ -29,6 +29,7 @@ type PayoutsConfig struct {
Gas string `json:"gas"`
GasPrice string `json:"gasPrice"`
AutoGas bool `json:"autoGas"`
MaxPriorityFee string `json:"maxPriorityFee"`
// In Shannon
Threshold int64 `json:"threshold"`
BgSave bool `json:"bgsave"`
@ -45,6 +46,11 @@ func (self PayoutsConfig) GasPriceHex() string {
return hexutil.EncodeBig(x)
}
func (self PayoutsConfig) MaxPriorityFeeHex() string {
x := util.String2Big(self.MaxPriorityFee)
return hexutil.EncodeBig(x)
}
type PayoutsProcessor struct {
config *PayoutsConfig
backend *storage.RedisClient
@ -179,7 +185,7 @@ func (u *PayoutsProcessor) process() {
}
value := hexutil.EncodeBig(amountInWei)
txHash, err := u.rpc.SendTransaction(u.config.Address, login, u.config.GasHex(), u.config.GasPriceHex(), value, u.config.AutoGas)
txHash, err := u.rpc.SendTransaction(u.config.Address, login, u.config.GasHex(), u.config.GasPriceHex(), u.config.MaxPriorityFeeHex(), value, u.config.AutoGas)
if err != nil {
log.Printf("Failed to send payment to %s, %v Shannon: %v. Check outgoing tx for %s in block explorer and docs/PAYOUTS.md",
login, amount, err, login)

7
rpc/rpc.go

@ -206,15 +206,20 @@ func (r *RPCClient) GetPeerCount() (int64, error) {
return strconv.ParseInt(strings.Replace(reply, "0x", "", -1), 16, 64)
}
func (r *RPCClient) SendTransaction(from, to, gas, gasPrice, value string, autoGas bool) (string, error) {
func (r *RPCClient) SendTransaction(from, to, gas, gasPrice, maxPriorityFee, value string, autoGas bool) (string, error) {
params := map[string]string{
"from": from,
"to": to,
"value": value,
}
if !autoGas {
// Sends as Legacy TX
params["gas"] = gas
params["gasPrice"] = gasPrice
} else {
// Sends as EIP1559 TX
params["gas"] = gas
params["maxPriorityFeePerGas"] = maxPriorityFee
}
rpcResp, err := r.doPost(r.Url, "eth_sendTransaction", []interface{}{params})
var reply string

Loading…
Cancel
Save