Skip to content

Commit

Permalink
fix 0 transaction in broadcast
Browse files Browse the repository at this point in the history
  • Loading branch information
boojamya committed Jan 31, 2024
1 parent c7f0bcb commit e6710c6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions noble/broadcast.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,13 @@ func (n *Noble) Broadcast(

// sign and broadcast txn
for attempt := 0; attempt <= n.maxRetries; attempt++ {
if err := n.attemptBroadcast(ctx, logger, msgs, sequenceMap, sdkContext, txBuilder); err == nil {
err := n.attemptBroadcast(ctx, logger, msgs, sequenceMap, sdkContext, txBuilder)
if err == nil {
return nil
}

// Log retry information
logger.Info(fmt.Sprintf("Retrying in %d seconds", n.retryIntervalSeconds))
logger.Error("Broadcasting to noble failed. Retrying...", "error", err, "interval_seconds", n.retryIntervalSeconds)
time.Sleep(time.Duration(n.retryIntervalSeconds) * time.Second)
}

Expand Down Expand Up @@ -120,6 +121,10 @@ func (n *Noble) attemptBroadcast(
msg.SourceTxHash))
}

if len(receiveMsgs) == 0 {
return nil
}

if err := txBuilder.SetMsgs(receiveMsgs...); err != nil {
return fmt.Errorf("failed to set messages on tx: %w", err)
}
Expand Down
2 changes: 1 addition & 1 deletion noble/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func (n *Noble) StartListener(
default:
block := <-blockQueue
res, err := n.cc.RPCClient.TxSearch(ctx, fmt.Sprintf("tx.height=%d", block), false, nil, nil, "")
if err != nil {
if err != nil || res == nil {
logger.Debug(fmt.Sprintf("unable to query Noble block %d", block), "error:", err)
blockQueue <- block
}
Expand Down

0 comments on commit e6710c6

Please sign in to comment.