Skip to content

feat: add network field to the go api#341

Merged
sczembor merged 2 commits into
masterfrom
stan/network_field
Nov 26, 2025
Merged

feat: add network field to the go api#341
sczembor merged 2 commits into
masterfrom
stan/network_field

Conversation

@sczembor
Copy link
Copy Markdown
Contributor

@sczembor sczembor commented Nov 25, 2025

Description

Closes: #XXXX


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title
  • added ! to the type prefix if API or client breaking change
  • added appropriate labels to the PR
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary

Summary by Sourcery

Add Bitcoin indexer client support for specifying the target network when sending blocks.

New Features:

  • Allow the Bitcoin indexer client to include a network identifier when submitting block data to the btcindexer API.

Enhancements:

  • Plumb network configuration from the relayer settings into the Bitcoin SPV indexer client initialization.

Build:

  • Update the btcindexer API dependency to a newer version that supports the network field.

Signed-off-by: sczembor <stanislaw.czembor@gmail.com>
@sczembor sczembor self-assigned this Nov 25, 2025
@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai Bot commented Nov 25, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR updates the Bitcoin indexer Go client to include a network identifier in API calls, wires that configuration through the CLI, and bumps the btcindexer API dependency to a version that supports the new network field.

Sequence diagram for btcindexer client initialization with network

sequenceDiagram
    actor Operator
    participant RelayerCLI as RelayerCLI
    participant Config as Config
    participant BtcIndexerClient as BtcIndexerClient

    Operator->>RelayerCLI: start bitcoin-spv
    RelayerCLI->>Config: load Config
    Config-->>RelayerCLI: Relayer.IndexerURL, Relayer.NetParams
    alt IndexerURL not configured
        RelayerCLI->>RelayerCLI: log BTC Indexer not configured
        RelayerCLI-->>Operator: continue without indexer
    else IndexerURL configured
        RelayerCLI->>BtcIndexerClient: NewClient(IndexerURL, NetParams, rootLogger)
        BtcIndexerClient-->>RelayerCLI: client with network field set
        RelayerCLI-->>Operator: run with configured indexer client
    end
Loading

Sequence diagram for preparePayload sending network to btcindexer API

sequenceDiagram
    participant Relayer as Relayer
    participant BtcIndexerClient as BtcIndexerClient
    participant BtcIndexerAPI as BtcIndexerAPI

    Relayer->>BtcIndexerClient: preparePayload(blocks)
    loop for each IndexedBlock
        BtcIndexerClient->>BtcIndexerClient: serialize block to blockBuffer
        BtcIndexerClient->>BtcIndexerClient: create PutBlock
        Note over BtcIndexerClient: PutBlock.Network = client.network
    end
    BtcIndexerClient-->>Relayer: []PutBlock with Network set
    Relayer->>BtcIndexerAPI: PutBlocks([]PutBlock)
    BtcIndexerAPI-->>Relayer: response based on Network and Height
Loading

Updated class diagram for btcindexer Client with network field

classDiagram
    class Client {
        - logger zerolog_Logger
        - apiClient btcindexer_Client
        - network string
        + NewClient(url string, network string, parentLogger zerolog_Logger) *Client
        + preparePayload(blocks []*types_IndexedBlock) (btcindexer_PutBlockRequest, error)
    }

    class zerolog_Logger
    class btcindexer_Client
    class types_IndexedBlock {
        + BlockHeight int64
        + Block interface
    }

    Client --> zerolog_Logger : uses
    Client --> btcindexer_Client : wraps
    Client --> types_IndexedBlock : prepares payload from
Loading

File-Level Changes

Change Details Files
Extend the btcindexer client to carry and send a network identifier on PutBlock requests.
  • Add a network field to the Client struct and store it in the constructor
  • Update NewClient signature to accept a network string parameter
  • Include the network value when constructing btcindexer.PutBlock payloads in preparePayload
bitcoinspv/clients/btcindexer/client.go
Wire relayer network configuration into the btcindexer client initialization.
  • Pass cfg.Relayer.NetParams as the network argument when creating the btcindexer client in initBtcIndexer
cmd/bitcoin-spv/cli.go
Update btcindexer API module to a version that supports the network field.
  • Bump github.com/gonative-cc/workers/api/btcindexer version in go.mod and refresh go.sum entries
go.mod
go.sum

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Signed-off-by: sczembor <stanislaw.czembor@gmail.com>
@sczembor sczembor merged commit 1d4f74a into master Nov 26, 2025
15 checks passed
@sczembor sczembor deleted the stan/network_field branch November 26, 2025 11:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants