Skip to content

Commit

Permalink
chore(transactor): Allow async forcing tx requests (#119)
Browse files Browse the repository at this point in the history
  • Loading branch information
calbera authored Oct 7, 2024
1 parent 592e7eb commit 14e608b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
2 changes: 1 addition & 1 deletion baseapp/runners.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ func (jm *JobManager) retryableHeaderSubscriber(
// Handle error while subscribing.
if shouldRetry = (err != nil); shouldRetry {
jm.Logger(ctx).Error(
"error subscribing to filter logs, retrying...",
"error subscribing to block headers, retrying...",
"job", blockHeaderJob.RegistryKey(), "err", err,
)
return shouldRetry
Expand Down
24 changes: 18 additions & 6 deletions core/transactor/transactor.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,16 +159,28 @@ func (t *TxrV2) SendTxRequest(txReq *types.Request) (string, error) {
// ForceTxRequest immediately (whenever the sender is free from any previous sends) builds and
// sends the tx request to the chain, after validating it.
// NOTE: this bypasses the queue and batching even if configured to do so.
func (t *TxrV2) ForceTxRequest(ctx context.Context, txReq *types.Request) (string, error) {
func (t *TxrV2) ForceTxRequest(ctx context.Context, txReq *types.Request, async bool) (string, error) {
if err := txReq.Validate(); err != nil {
return "", err
}

go t.fire(
ctx,
&tracker.Response{MsgIDs: []string{txReq.MsgID}, InitialTimes: []time.Time{txReq.Time()}},
true, txReq.CallMsg,
)
if async {
go t.fire(
ctx,
&tracker.Response{
MsgIDs: []string{txReq.MsgID}, InitialTimes: []time.Time{txReq.Time()},
},
true, txReq.CallMsg,
)
} else {
t.fire(
ctx,
&tracker.Response{
MsgIDs: []string{txReq.MsgID}, InitialTimes: []time.Time{txReq.Time()},
},
true, txReq.CallMsg,
)
}
return txReq.MsgID, nil
}

Expand Down
2 changes: 0 additions & 2 deletions x/jobs/block_header_job.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ func (w *BlockHeaderWatcher) Subscribe(
return nil, nil, err
}
w.sub = sub

sCtx.Logger().Info("Subscribed to new block headers")
return sub, headerCh, nil
}

Expand Down

0 comments on commit 14e608b

Please sign in to comment.