Skip to content

Commit 4a2d4cc

Browse files
committed
Address comments
1 parent 83ad9d2 commit 4a2d4cc

1 file changed

Lines changed: 25 additions & 22 deletions

File tree

pkg/txm/clientwrappers/dualbroadcast/meta_client.go

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ func (a *MetaClient) PendingNonceAt(ctx context.Context, address common.Address)
170170
return a.c.PendingNonceAt(ctx, address)
171171
}
172172

173-
// SendTransactions handles three diffenent cases:
173+
// SendTransactions handles three different cases:
174174
// 1. Auctions & Sends an attempt if it's a meta transaction and it hasn't broadcasted before.
175175
// 2. Sends the first attempt if it's a meta transaction and it has broadcasted before. This covers RPC errors.
176176
// 3. Sends an empty transaction to the mempool to clear the nonce.
@@ -180,30 +180,33 @@ func (a *MetaClient) SendTransaction(ctx context.Context, tx *types.Transaction,
180180
return err
181181
}
182182

183-
if !tx.IsPurgeable {
184-
if meta != nil &&
185-
meta.DualBroadcast != nil && *meta.DualBroadcast && meta.DualBroadcastParams != nil && meta.FwdrDestAddress != nil &&
186-
tx.AttemptCount == 1 {
187-
meta, err := a.SendRequest(ctx, tx, attempt, *meta.DualBroadcastParams, tx.ToAddress)
188-
if err != nil {
189-
a.metrics.RecordSendRequestError(ctx)
190-
return fmt.Errorf("error sending request for transactionID(%d): %w", tx.ID, ErrAuction)
191-
}
192-
if meta != nil {
193-
if err := a.SendOperation(ctx, tx, attempt, *meta); err != nil {
194-
a.metrics.RecordSendOperationError(ctx)
195-
return fmt.Errorf("failed to send operation for transactionID(%d): %w", tx.ID, ErrAuction)
196-
}
197-
return nil
198-
}
199-
a.lggr.Infof("No bids for transactionID(%d): ", tx.ID)
200-
return ErrNoBids
183+
// #1
184+
if meta != nil &&
185+
meta.DualBroadcast != nil && *meta.DualBroadcast && meta.DualBroadcastParams != nil && meta.FwdrDestAddress != nil &&
186+
tx.AttemptCount == 1 && !tx.IsPurgeable {
187+
// Auction & Validate
188+
meta, err := a.SendRequest(ctx, tx, attempt, *meta.DualBroadcastParams, tx.ToAddress)
189+
if err != nil {
190+
a.metrics.RecordSendRequestError(ctx)
191+
return fmt.Errorf("error sending request for transactionID(%d): %w", tx.ID, errors.Join(err, ErrAuction))
201192
}
202-
if len(tx.Attempts) > 1 {
203-
a.lggr.Infow("Intercepted attempt for tx(rebroadcasting first attempt)", "txID", tx.ID, "attempt", tx.Attempts[0])
204-
return a.c.SendTransaction(ctx, tx.Attempts[0].SignedTransaction)
193+
// Send Metacall
194+
if meta != nil {
195+
if err := a.SendOperation(ctx, tx, attempt, *meta); err != nil {
196+
a.metrics.RecordSendOperationError(ctx)
197+
return fmt.Errorf("failed to send operation for transactionID(%d): %w", tx.ID, errors.Join(err, ErrAuction))
198+
}
199+
return nil
205200
}
201+
a.lggr.Infof("No bids for transactionID(%d): ", tx.ID)
202+
return ErrNoBids
203+
}
204+
// #2
205+
if !tx.IsPurgeable && len(tx.Attempts) > 1 {
206+
a.lggr.Infow("Intercepted attempt for tx(rebroadcasting first attempt)", "txID", tx.ID, "attempt", tx.Attempts[0])
207+
return a.c.SendTransaction(ctx, tx.Attempts[0].SignedTransaction)
206208
}
209+
// #3
207210
a.lggr.Infow("Broadcasting attempt to public mempool", "tx", tx)
208211
return a.c.SendTransaction(ctx, attempt.SignedTransaction)
209212
}

0 commit comments

Comments
 (0)