@@ -120,7 +120,7 @@ func (w *WorkerSolana) Listen(ctx context.Context) error {
120120 //schedulingDone = w.scheduler.runScheduler(ctxwc)
121121
122122 //// Retrieve logs asynchronously.
123- pollDone , txCh := w .pollNewSignatures (ctxwc )
123+ pollDone , txCh := w .pollNewTransactions (ctxwc )
124124
125125 // Start processing transactions
126126 procDone := w .processTransactions (ctxwc , txCh )
@@ -148,26 +148,26 @@ func (w *WorkerSolana) Listen(ctx context.Context) error {
148148 return nil
149149}
150150
151- // pollNewSignatures continuously fetches only new signatures touching your program,
152- // then loads each confirmed transaction so you can parse its LogMessages.
153- func (w * WorkerSolana ) pollNewSignatures (
151+ // pollNewTransactions continuously fetches only new txs touching the program,
152+ // then loads each confirmed transaction so it can parse its LogMessages.
153+ func (w * WorkerSolana ) pollNewTransactions (
154154 ctx context.Context ,
155155) (<- chan struct {}, <- chan * rpc.TransactionWithMeta ) {
156156 done := make (chan struct {})
157157 txCh := make (chan * rpc.TransactionWithMeta , w .pollSize )
158158
159159 go func () {
160160 defer func () {
161- w .logger .Info ("pollNewSignatures exiting" )
161+ w .logger .Info ("pollNewTransactions exiting" )
162162 close (done )
163163 close (txCh )
164164 }()
165165
166- w .logger .Infof (
167- "starting pollNewSignatures: program=%s pollPeriod=%ds pollSize=%d " ,
168- w .timelockProgramKey ,
169- w .pollPeriod ,
170- w .pollSize ,
166+ w .logger .Infow (
167+ "starting pollNewTransactions " ,
168+ "program" , w .timelockProgramKey ,
169+ "pollPeriod" , w .pollPeriod ,
170+ "pollSize" , w .pollSize ,
171171 )
172172
173173 ticker := time .NewTicker (time .Duration (w .pollPeriod ) * time .Second )
@@ -180,7 +180,7 @@ func (w *WorkerSolana) pollNewSignatures(
180180 return
181181
182182 case <- ticker .C :
183- w .logger .Infof ("new pollNewSignatures tick: %s " , time .Now ().Format (time .RFC3339 ))
183+ w .logger .Infow ("new pollNewTransactions" , " tick" , time .Now ().Format (time .RFC3339 ))
184184
185185 var until solana.Signature
186186 if w .lastSignature != nil {
@@ -210,7 +210,7 @@ func (w *WorkerSolana) pollNewSignatures(
210210 continue
211211 }
212212
213- w .logger .Infof ("found %d new signatures" , len (sigs ))
213+ w .logger .Infow ("found new signatures" , "num signatures" , len (sigs ))
214214
215215 // Build JSON-RPC batch requests (oldest→newest)
216216 requests := make (jsonrpc.RPCRequests , len (sigs ))
@@ -303,7 +303,7 @@ func (w *WorkerSolana) handleTx(ctx context.Context, tx *rpc.TransactionWithMeta
303303 return nil
304304 }
305305
306- timelockEvent , err := ParseTimelockEvents (w . logger , tx )
306+ timelockEvent , err := ParseTimelockEvents (tx )
307307 if err != nil {
308308 return fmt .Errorf ("failed to parse timelock events: %w" , err )
309309 }
@@ -337,16 +337,16 @@ func (w *WorkerSolana) handleTx(ctx context.Context, tx *rpc.TransactionWithMeta
337337}
338338
339339// handleEventCancelled checks if the operation is cancelled and deletes it from the scheduler if it is.
340- func (w * WorkerSolana ) handleEventCancelled (_ context.Context , event Cancelled ) {
340+ func (w * WorkerSolana ) handleEventCancelled (_ context.Context , event SolanaTimelockCallCancelledEvent ) {
341341 w .logger .With (operationID , fmt .Sprintf ("%x" , event .ID )).
342- Infof ( "%s received, cancelling operation" , eventCancelled )
342+ Infow ( "event received, cancelling operation" , "event type " , eventCancelled )
343343
344344 // TODO: add scheduler call once scheduler is implemented
345345 //w.scheduler.delFromScheduler(event.ID)
346346}
347347
348348// handleEventExecuted checks if the operation is done and deletes it from the scheduler if it is.
349- func (w * WorkerSolana ) handleEventExecuted (ctx context.Context , event CallExecuted ) error {
349+ func (w * WorkerSolana ) handleEventExecuted (ctx context.Context , event SolanaTimelockCallExecutedEvent ) error {
350350 logger := w .logger .With (eventIndex , fmt .Sprintf ("%x" , event .Index )).
351351 With (eventTarget , event .Target .String ()).
352352 With (operationID , fmt .Sprintf ("%x" , event .ID ))
@@ -356,7 +356,7 @@ func (w *WorkerSolana) handleEventExecuted(ctx context.Context, event CallExecut
356356 return fmt .Errorf ("timelock.isOperationDone call failed (operation id: %x): %w" , event .ID , err )
357357 }
358358 if isDone {
359- logger .Infof ( "%s received, deleting operation from scheduler" , eventCallExecuted )
359+ logger .Infow ( "event received, deleting operation from scheduler" , "event type " , eventCallExecuted )
360360 // TODO: add scheduler call once scheduler is implemented
361361 //w.scheduler.delFromScheduler(event.ID)
362362 } else {
@@ -367,7 +367,7 @@ func (w *WorkerSolana) handleEventExecuted(ctx context.Context, event CallExecut
367367}
368368
369369// handleEventScheduled checks if the operation is already scheduled and adds it to the scheduler if it is not.
370- func (w * WorkerSolana ) handleEventScheduled (ctx context.Context , event CallScheduled ) error {
370+ func (w * WorkerSolana ) handleEventScheduled (ctx context.Context , event SolanaTimelockCallScheduledEvent ) error {
371371 logger := w .logger .With (eventIndex , fmt .Sprintf ("%x" , event .Index )).
372372 With (eventTarget , event .Target .String ()).
373373 With (operationID , fmt .Sprintf ("%x" , event .ID ))
@@ -383,7 +383,7 @@ func (w *WorkerSolana) handleEventScheduled(ctx context.Context, event CallSched
383383 }
384384
385385 if isOp {
386- logger .Infof ( "%s received" , eventCallScheduled )
386+ logger .Infow ( "event received" , "event type " , eventCallScheduled )
387387 // TODO: add scheduler call once scheduler is implemented
388388 // w.scheduler.addToScheduler(cs)
389389 } else {
@@ -397,12 +397,12 @@ func (w *WorkerSolana) handleEventScheduled(ctx context.Context, event CallSched
397397// startLog prints the timelock-worker configuration.
398398func (w * WorkerSolana ) startLog () {
399399 w .logger .Info ("timelock-worker started [solana]" )
400- w .logger .Infof ("\t Timelock program addresses: %v" , w .timelockProgramKey .String ())
400+ w .logger .Infow ("\t Timelock program addresses: %v" , w .timelockProgramKey .String ())
401401
402402 wallet := w .privateKey .PublicKey ()
403403
404- w .logger .Infof ("\t Solana account address: %v" , wallet )
405- w .logger .Infof ("\t Poll Period: %v" , time .Duration (w .pollPeriod * int64 (time .Second )).String ())
406- w .logger .Infof ("\t Event Listener Poll Period: %v" , time .Duration (w .listenerPollPeriod * int64 (time .Second )).String ())
407- w .logger .Infof ("\t Event Listener Poll #Logs: %v" , w .pollSize )
404+ w .logger .Infow ("\t Solana account address: %v" , wallet )
405+ w .logger .Infow ("\t Poll Period: %v" , time .Duration (w .pollPeriod * int64 (time .Second )).String ())
406+ w .logger .Infow ("\t Event Listener Poll Period: %v" , time .Duration (w .listenerPollPeriod * int64 (time .Second )).String ())
407+ w .logger .Infow ("\t Event Listener Poll #Logs: %v" , w .pollSize )
408408}
0 commit comments