@@ -26,7 +26,7 @@ import (
2626// Distribute minipools task
2727type DistributeMinipools struct {
2828 sp * services.ServiceProvider
29- log log.ColorLogger
29+ log * log.ColorLogger
3030 cfg * config.SmartNodeConfig
3131 w * wallet.Wallet
3232 rp * rocketpool.RocketPool
@@ -42,46 +42,54 @@ type DistributeMinipools struct {
4242
4343// Create distribute minipools task
4444func NewDistributeMinipools (sp * services.ServiceProvider , logger log.ColorLogger ) * DistributeMinipools {
45+ cfg := sp .GetConfig ()
46+ log := & logger
47+ maxFee , maxPriorityFee := getAutoTxInfo (cfg , log )
48+ gasThreshold := cfg .AutoTxGasThreshold .Value
49+
50+ if gasThreshold == 0 {
51+ log .Println ("Automatic tx gas threshold is 0, disabling auto-distribute." )
52+ }
53+
54+ distributeThresholdFloat := cfg .DistributeThreshold .Value
55+ // Safety clamp
56+ if distributeThresholdFloat >= 8 {
57+ log .Printlnf ("WARNING: Auto-distribute threshold is more than 8 ETH (%.6f ETH), reducing to 7.5 ETH for safety" , distributeThresholdFloat )
58+ distributeThresholdFloat = 7.5
59+ } else if distributeThresholdFloat == 0 {
60+ log .Println ("Auto-distribute threshold is 0, disabling auto-distribute." )
61+ return nil
62+ }
63+ distributeThreshold := eth .EthToWei (distributeThresholdFloat )
64+
4565 return & DistributeMinipools {
46- sp : sp ,
47- log : logger ,
48- eight : eth .EthToWei (8 ),
66+ sp : sp ,
67+ log : log ,
68+ cfg : cfg ,
69+ w : sp .GetWallet (),
70+ rp : sp .GetRocketPool (),
71+ bc : sp .GetBeaconClient (),
72+ d : sp .GetDocker (),
73+ gasThreshold : gasThreshold ,
74+ distributeThreshold : distributeThreshold ,
75+ maxFee : maxFee ,
76+ maxPriorityFee : maxPriorityFee ,
77+ eight : eth .EthToWei (8 ),
4978 }
5079}
5180
5281// Distribute minipools
5382func (t * DistributeMinipools ) Run (state * state.NetworkState ) error {
54- // Get services
55- t .cfg = t .sp .GetConfig ()
56- t .w = t .sp .GetWallet ()
57- t .rp = t .sp .GetRocketPool ()
58- t .bc = t .sp .GetBeaconClient ()
59- t .d = t .sp .GetDocker ()
60- t .w = t .sp .GetWallet ()
61- nodeAddress , _ := t .w .GetAddress ()
62- t .maxFee , t .maxPriorityFee = getAutoTxInfo (t .cfg , & t .log )
63- t .gasThreshold = t .cfg .AutoTxGasThreshold .Value
64-
6583 // Check if auto-distributing is disabled
6684 if t .gasThreshold == 0 {
67- t .log .Println ("Automatic tx gas threshold is 0, disabling auto-distribute." )
68- return nil
69- }
70- distributeThreshold := t .cfg .DistributeThreshold .Value
71- // Safety clamp
72- if distributeThreshold >= 8 {
73- t .log .Printlnf ("WARNING: Auto-distribute threshold is more than 8 ETH (%.6f ETH), reducing to 7.5 ETH for safety" , distributeThreshold )
74- distributeThreshold = 7.5
75- } else if distributeThreshold == 0 {
76- t .log .Println ("Auto-distribute threshold is 0, disabling auto-distribute." )
7785 return nil
7886 }
79- t .distributeThreshold = eth .EthToWei (distributeThreshold )
8087
8188 // Log
8289 t .log .Println ("Checking for minipools to distribute..." )
8390
8491 // Get prelaunch minipools
92+ nodeAddress , _ := t .w .GetAddress ()
8593 minipools , err := t .getDistributableMinipools (nodeAddress , state )
8694 if err != nil {
8795 return err
@@ -191,7 +199,7 @@ func (t *DistributeMinipools) distributeMinipools(submissions []*eth.Transaction
191199 // Get the max fee
192200 maxFee := t .maxFee
193201 if maxFee == nil || maxFee .Uint64 () == 0 {
194- maxFee , err = gas .GetMaxFeeWeiForDaemon (& t .log )
202+ maxFee , err = gas .GetMaxFeeWeiForDaemon (t .log )
195203 if err != nil {
196204 return err
197205 }
@@ -200,7 +208,7 @@ func (t *DistributeMinipools) distributeMinipools(submissions []*eth.Transaction
200208 opts .GasTipCap = t .maxPriorityFee
201209
202210 // Print the gas info
203- if ! gas .PrintAndCheckGasInfoForBatch (submissions , true , t .gasThreshold , & t .log , maxFee ) {
211+ if ! gas .PrintAndCheckGasInfoForBatch (submissions , true , t .gasThreshold , t .log , maxFee ) {
204212 return nil
205213 }
206214
@@ -213,7 +221,7 @@ func (t *DistributeMinipools) distributeMinipools(submissions []*eth.Transaction
213221 }
214222
215223 // Print TX info and wait for them to be included in a block
216- err = tx .PrintAndWaitForTransactionBatch (t .cfg , t .rp , & t .log , submissions , callbacks , opts )
224+ err = tx .PrintAndWaitForTransactionBatch (t .cfg , t .rp , t .log , submissions , callbacks , opts )
217225 if err != nil {
218226 return err
219227 }
0 commit comments