mempool_explorer

package
v0.0.0-...-3b18725 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 24, 2026 License: MIT Imports: 30 Imported by: 0

Documentation

Overview

Package explorer provides an explorer client with support for multiple concurrent WebSocket connections for addresses tracking.

Architecture

  • Multiple concurrent WebSocket connections
  • Hash-based address distribution for consistent routing
  • Automatic fallback to polling if WebSocket connections fails

Usage

Basic usage with default settings:

svc, err := explorer.NewExplorer("", arklib.Bitcoin, explorer.WithTracker(true))
if err != nil {
    log.Fatal(err)
}
defer svc.Stop()

Subscribe to addresses:

addresses := []string{"bc1q...", "bc1p...", ...}
if err := svc.SubscribeForAddresses(addresses); err != nil {
    log.Fatal(err)
}

// Listen for events
for event := range svc.GetAddressesEvents() {
    fmt.Printf("New UTXOs: %d, Spent: %d\n", len(event.NewUtxos), len(event.SpentUtxos))
}

Thread Safety

All public methods are thread-safe and can be called concurrently.

Index

Constants

View Source
const (
	BitcoinExplorer = "bitcoin"
)

Variables

This section is empty.

Functions

func NewExplorer

func NewExplorer(baseUrl string, net arklib.Network, opts ...Option) (explorer.Explorer, error)

NewExplorer creates a new Explorer instance for the specified network. If baseUrl is empty, it uses the default explorer URL for the network.

The explorer supports:

  • Multiple concurrent WebSocket connections for scalability
  • Automatic fallback to polling if WebSocket connections fail

Example:

svc, err := explorer.NewExplorer("https://mempool.space/api", arklib.Bitcoin, explorer.WithTracker(true))

Types

type Option

type Option func(*explorerSvc)

Option is a functional option for configuring the Explorer service.

func WithPollInterval

func WithPollInterval(interval time.Duration) Option

WithPollInterval sets the polling interval for address tracking when WebSocket is unavailable. Default: 10 seconds.

func WithTracker

func WithTracker(withTracker bool) Option

WithTracker enables or disables address tracking. When disabled, the explorer only provides REST API functionality without WebSocket connections. Default: tracking is disabled.

type RBFTxn

type RBFTxn struct {
	TxId       string
	ReplacedBy string
}

type RbfTxId

type RbfTxId struct {
	TxId string `json:"txid"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL