@@ -105,12 +105,15 @@ func CreateFastUpdatesClient(cfg *config.Config, valuesProvider provider.ValuesP
105105 fastUpdatesClient .transactionAccounts [i ].Address = crypto .PubkeyToAddress (* publicKeyECDSA )
106106 }
107107
108- fastUpdatesClient .fastUpdater , err = fast_updater .NewFastUpdater (
109- common .HexToAddress (cfg .Client .FastUpdaterAddress ), fastUpdatesClient .chainClient ,
110- )
111- if err != nil {
112- return nil , fmt .Errorf ("CreateFastUpdatesClient: NewFastUpdater: %w" , err )
108+ if cfg .Client .FastUpdaterAddress != "" {
109+ fastUpdatesClient .fastUpdater , err = fast_updater .NewFastUpdater (
110+ common .HexToAddress (cfg .Client .FastUpdaterAddress ), fastUpdatesClient .chainClient ,
111+ )
112+ if err != nil {
113+ return nil , fmt .Errorf ("CreateFastUpdatesClient: NewFastUpdater: %w" , err )
114+ }
113115 }
116+
114117 fastUpdatesClient .IncentiveManager , err = incentive .NewIncentive (
115118 common .HexToAddress (cfg .Client .IncentiveManagerAddress ), fastUpdatesClient .chainClient ,
116119 )
@@ -134,6 +137,11 @@ func CreateFastUpdatesClient(cfg *config.Config, valuesProvider provider.ValuesP
134137 }
135138 }
136139
140+ err = fastUpdatesClient .UpdateFastUpdaterContractAddress ()
141+ if err != nil {
142+ return nil , err
143+ }
144+
137145 fastUpdatesClient .flareSystemMock , err = mock .NewMock (
138146 common .HexToAddress (cfg .Client .MockAddress ), fastUpdatesClient .chainClient ,
139147 )
@@ -209,6 +217,11 @@ func (client *FastUpdatesClient) Run(startBlock, endBlock uint64) error {
209217 logger .Info ("Fetched feed ids: %v" , client .allFeeds )
210218
211219 for {
220+ err = client .UpdateFastUpdaterContractAddress ()
221+ if err != nil {
222+ logger .Error ("Failed attempt in updating the FastUpdater contract address: %s" , err )
223+ }
224+
212225 if blockNum % refreshFeedsBlockInterval == 0 {
213226 client .allFeeds , err = client .GetCurrentFeedIds ()
214227 if err != nil {
@@ -295,7 +308,6 @@ func (client *FastUpdatesClient) Run(startBlock, endBlock uint64) error {
295308 }
296309}
297310
298-
299311func (client * FastUpdatesClient ) GetBlockScoreCutoffWithRepeats (blockNum uint64 ) (* big.Int , error ) {
300312 var cutoff * big.Int
301313 var err error
@@ -320,3 +332,27 @@ func (client *FastUpdatesClient) WaitToEmptyRequests() {
320332func (client * FastUpdatesClient ) Stop () {
321333 client .transactionQueue .StopQueue ()
322334}
335+
336+ func (client * FastUpdatesClient ) UpdateFastUpdaterContractAddress () error {
337+ if client .submission == nil {
338+ return nil
339+ }
340+
341+ newAddress , err := client .GetFastUpdaterContractAddress ()
342+ if err != nil {
343+ return err
344+ }
345+ if newAddress != common .HexToAddress (client .params .FastUpdaterAddress ) {
346+ client .fastUpdater , err = fast_updater .NewFastUpdater (
347+ newAddress , client .chainClient ,
348+ )
349+ if err != nil {
350+ return err
351+ }
352+
353+ client .params .FastUpdaterAddress = newAddress .Hex ()
354+ logger .Info ("Updated the FastUpdater address to %s" , client .params .FastUpdaterAddress )
355+ }
356+
357+ return nil
358+ }
0 commit comments