Skip to content
This repository has been archived by the owner on Apr 2, 2024. It is now read-only.

Commit

Permalink
Only broadcast to NowNodes if loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
mrz1836 committed May 3, 2022
1 parent a4e64a2 commit 0e299ed
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions chainstate/broadcast.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,18 +126,20 @@ func (c *Client) broadcast(ctx context.Context, id, hex string, timeout time.Dur

// Try next provider: NowNodes
provider = providerNowNodes
if err = broadcastNowNodes(ctx, c, c.NowNodes(), id, id, hex); err != nil {
if c.NowNodes() != nil { // Only if NowNodes is loaded (requires API key)
if err = broadcastNowNodes(ctx, c, c.NowNodes(), id, id, hex); err != nil {

// Check error response for (TX FAILURE)
if doesErrorContain(err.Error(), broadcastQuestionableErrors) {
err = checkInMempool(ctx, c, id, err.Error(), timeout)
return // Success, found in mempool (or on-chain)
}
// Check error response for (TX FAILURE)
if doesErrorContain(err.Error(), broadcastQuestionableErrors) {
err = checkInMempool(ctx, c, id, err.Error(), timeout)
return // Success, found in mempool (or on-chain)
}

// Provider error?
c.DebugLog("broadcast error: " + err.Error() + " from provider: " + providerNowNodes)
} else { // Success!
return
// Provider error?
c.DebugLog("broadcast error: " + err.Error() + " from provider: " + providerNowNodes)
} else { // Success!
return
}
}

// Final error - all failures
Expand Down

0 comments on commit 0e299ed

Please sign in to comment.