Skip to content

Commit

Permalink
fix(ARCO-212): No error if tx not in mempool
Browse files Browse the repository at this point in the history
  • Loading branch information
boecklim committed Nov 20, 2024
1 parent fb41eef commit 4f28f61
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
7 changes: 7 additions & 0 deletions internal/node_client/node_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"errors"
"fmt"
"runtime"
"strings"

sdkTx "github.com/bitcoin-sv/go-sdk/transaction"
"github.com/ordishs/go-bitcoin"
Expand Down Expand Up @@ -50,6 +51,8 @@ func New(n *bitcoin.Bitcoind, opts ...func(client *NodeClient)) (NodeClient, err
return node, nil
}

var ErrTransactionNotInMempool = errors.New("Transaction not in mempool")

func (n NodeClient) GetMempoolAncestors(ctx context.Context, ids []string) ([]string, error) {
_, span := tracing.StartTracing(ctx, "NodeClient_GetMempoolAncestors", n.tracingEnabled, n.tracingAttributes...)
defer tracing.EndTracing(span)
Expand All @@ -61,6 +64,10 @@ func (n NodeClient) GetMempoolAncestors(ctx context.Context, ids []string) ([]st
nTx, err := n.bitcoinClient.GetMempoolAncestors(id, false)
tracing.EndTracing(span)
if err != nil {
if strings.Contains(err.Error(), "Transaction not in mempool") {
continue
}

return nil, errors.Join(ErrFailedToGetMempoolAncestors, err)
}

Expand Down
6 changes: 6 additions & 0 deletions internal/node_client/node_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,5 +155,11 @@ func TestNodeClient(t *testing.T) {

// then
require.ErrorIs(t, err, node_client.ErrFailedToGetMempoolAncestors)

// when
_, err = sut.GetMempoolAncestors(ctx, []string{"792bb5c0d5e4937572e6368dc713ba0b4935d27a7b7ac654c2b384d6c8b2fb89"})

// then
require.ErrorIs(t, err, node_client.ErrTransactionNotInMempool)
})
}

0 comments on commit 4f28f61

Please sign in to comment.