From 0e299ede6c1b6e9fd5ea0907c2b99d2423f1c5a8 Mon Sep 17 00:00:00 2001 From: mrz1836 Date: Tue, 3 May 2022 19:59:56 -0400 Subject: [PATCH] Only broadcast to NowNodes if loaded --- chainstate/broadcast.go | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/chainstate/broadcast.go b/chainstate/broadcast.go index 28b96242..66dd52d2 100644 --- a/chainstate/broadcast.go +++ b/chainstate/broadcast.go @@ -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