chains

package
v0.0.0-...-4427c07 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2026 License: AGPL-3.0 Imports: 59 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrFork = errors.New("block ancestry conflicts with a completed neighbor")

ErrFork marks a provider response incompatible with an already accepted neighbor.

View Source
var ErrRateLimited = errors.New("RPC HTTP 429")
View Source
var ErrTransactionData = errors.New("incomplete or mismatched transaction")
View Source
var ErrTransactionMissing = errors.New("transaction not found")
View Source
var ErrTransactionPending = errors.New("transaction is pending confirmation")

Functions

func BitcoinRPCHeight

func BitcoinRPCHeight(ctx context.Context, n Network) (int64, error)

Bitcoin Core nodes expose a mainnet height for the node inventory.

func Canonical

func Canonical(n, a string) (string, error)

func ConnectTONPeer

func ConnectTONPeer(ctx context.Context, pool *liteclient.ConnectionPool, raw string) error

ConnectTONPeer authenticates a direct LiteServer and verifies its mainnet genesis.

func EVMChainID

func EVMChainID(name string) int64

func EVMNetworks

func EVMNetworks() iter.Seq[string]

func EndpointProtocol

func EndpointProtocol(n Network) (string, error)

EndpointProtocol resolves the transport, including legacy configured URLs.

func IsEVM

func IsEVM(name string) bool

func LookupHead

func LookupHead(ctx context.Context, n Network, public bool) (int64, error)

Check availability without sending the caller's transaction hash.

func LookupTransaction

func LookupTransaction(ctx context.Context, n Network, hash string, public bool) (json.RawMessage, error)

func NativeAsset

func NativeAsset(name string) string

NativeAsset identifies the top-level value-transfer assets supported by the new EVM adapters. All use 18 decimals for JSON-RPC transaction value.

func NeedsHistory

func NeedsHistory(network, protocol string) bool

func NodeHead

func NodeHead(ctx context.Context, src Source, n Network) (int64, error)

A paired scanner can follow a history provider's cursor. A node test must report a height observed on the selected primary interface.

func ProbePublicRPC

func ProbePublicRPC(ctx context.Context, n Network) (int64, error)

Probe a recent numbered block, catching stuck nodes and endpoints that answer a height request but cannot serve even the corresponding header.

func ProbePublicScan

func ProbePublicScan(ctx context.Context, n Network) (int64, error)

ProbePublicScan exercises the scanner's history read before admission.

func Protocols

func Protocols(network string) []string

Protocols lists selectable node interfaces in preferred order. HTTP is retained for configurations created before explicit protocol selection.

func ProviderKey

func ProviderKey(n Network) string

Different credentials, paths, or transports on one host and port do not identify different providers. A paired node uses its history provider's key.

func PublicRPCProtocol

func PublicRPCProtocol(raw string) string

Public directory entries are third-party input. Apply the same dial policy during discovery, admin tests and actual scanning, including websocket reconnects.

func ReadSpan

func ReadSpan(ctx context.Context, network string, s Source, r Span) (Span, BlockLink, []Activity, error)

ReadSpan returns one complete adapter response, including the exact boundary of a partial Aptos page. A linked EVM source must identify both neighbors.

func RedactError

func RedactError(err error, n Network) string

func SharesScanSource

func SharesScanSource(n Network, scanned map[string]bool) bool

func SourceIDs

func SourceIDs(n Network) []string

SourceIDs identifies both sides of paired transports. Only opaque identities for matched transactions are retained after the scan has committed.

func Supported

func Supported(name string) bool

func TONIndexHeight

func TONIndexHeight(ctx context.Context, n Network) (int64, error)

func TONReadSlice

func TONReadSlice(ctx context.Context, n Network, master *ton.BlockIDExt, contract *address.Address, method string, arg *cell.Cell) (*cell.Slice, error)

TONReadSlice runs a historical getter with one slice argument and one slice result. Payment consumers use it to verify contracts against the same block that produced an activity. The caller interprets the return value.

func TONVoter

func TONVoter(n Network) (host, identity string, ok bool)

Only pinned direct peers can vote. A global-config URL may select the same backing peer twice. Both socket host and Ed25519 identity are deduplicated.

func TransactionEvidence

func TransactionEvidence(n Network, raw json.RawMessage) (json.RawMessage, error)

TransactionEvidence validates and projects a single successful, identity-checked read from one node.

func TransactionHash

func TransactionHash(network, raw string) (string, error)

func UniSatHeight

func UniSatHeight(ctx context.Context, n Network) (int64, error)

func ValidateEndpoint

func ValidateEndpoint(n Network) error

ValidateEndpoint checks a primary endpoint before a history node is selected.

func ValidateNetwork

func ValidateNetwork(n Network) error

func VerifyTON

func VerifyTON(ctx context.Context, n Network, hash string, loc TONLocation) (json.RawMessage, error)

func Wakeups

func Wakeups(s Source) <-chan struct{}

Wakeups coalesces tip notifications. The persisted cursor determines the next read even when a stream drops notifications or reconnects after an outage.

Types

type Activity

type Activity struct {
	ScanFallback  bool            `json:"-"` // Role of the endpoint that supplied this block.
	ScanSources   []string        `json:"-"` // Internal provenance for the committed block read.
	Confirmations int64           `json:"confirmations"`
	Network       string          `json:"network"`
	Height        int64           `json:"height"`
	TxID          string          `json:"tx_id"`
	TimeMS        int64           `json:"time_ms"`
	Addresses     []string        `json:"addresses"`
	Data          json.RawMessage `json:"data"`
}

Activity carries chain evidence, including failed and outgoing transactions. A subscriber is responsible for interpreting it.

func SuiTransaction

func SuiTransaction(ctx context.Context, n Network, digest string) (Activity, error)

SuiTransaction retrieves finalized evidence for an explicit transaction lookup using the same fields as the checkpoint scanner.

type AssetEventLayout

type AssetEventLayout struct {
	Topics       int   `json:"topics"`                  // includes topic0
	DataWords    int   `json:"data_words"`              // exact number of non-indexed, static 32-byte words
	AddressWords []int `json:"address_words,omitempty"` // zero-based offsets of address arguments
	RefreshAsset bool  `json:"refresh_asset,omitempty"` // emitting token has a global balance update
}

type AssetEventRules

type AssetEventRules map[common.Address]map[common.Hash]AssetEventLayout

AssetEventRules maps an emitting contract and topic0 to its fixed ABI layout. Treat a configured rule set as immutable after handing it to a scanner.

type BlockLink struct{ Hash, Parent string }

BlockLink identifies the exact EVM block whose transactions were decoded.

type Evidence

type Evidence struct {
	RefreshAssets []string          `json:"refresh_assets,omitempty"`
	Transaction   json.RawMessage   `json:"transaction"`
	Logs          []json.RawMessage `json:"logs,omitempty"`
	Receipt       json.RawMessage   `json:"receipt,omitempty"`
	Trace         json.RawMessage   `json:"trace,omitempty"`
}

type FinishRange

type FinishRange = func(Span, BlockLink, []Activity, error) error

type Network

type Network struct {
	AssetEvents     *AssetEventRules `json:"asset_events,omitempty"`
	Protocol        string           `json:"protocol,omitempty"`
	HistoryURL      string           `json:"history_url,omitempty"`
	HistoryAPIKey   string           `json:"history_api_key,omitempty"`
	Name            string           `json:"name"`
	URL             string           `json:"url"`
	APIKey          string           `json:"api_key,omitempty"`
	Confirmations   int64            `json:"confirmations,omitempty"`
	IntervalSeconds int              `json:"interval_seconds,omitempty"`
	Lookback        int64            `json:"lookback,omitempty"`
	TraceCalls      bool             `json:"trace_calls,omitempty"`
}

func LookupRoute

func LookupRoute(n Network) (Network, bool)

LookupRoute resolves paired interfaces to the actual history endpoint. Stream aliases must neither receive duplicate work nor count as additional votes.

func (Network) UsesHistory

func (n Network) UsesHistory(protocol string) bool

Avalanche WebSockets may either serve execution RPC directly or supply only newHeads, with an HTTP companion performing all execution reads.

func (Network) ValidateAssetEvents

func (n Network) ValidateAssetEvents() error

type Source

type Source interface {
	Head(context.Context) (int64, error)
	Read(ctx context.Context, next, head int64) (end int64, events []Activity, err error)
	Close()
}

Source returns contiguous confirmed heights (ledger versions for Aptos).

func NewPublicSource

func NewPublicSource(ctx context.Context, n Network) (Source, error)

func NewSource

func NewSource(ctx context.Context, n Network) (Source, error)

type Span

type Span struct {
	First, Last int64
	Failed      bool // a previous scan attempt for this range failed
}

Span is an inclusive range of block heights (ledger versions on Aptos).

type TONData

type TONData struct {
	Account string
	BOC     []byte
	Master  *ton.BlockIDExt
}

type TONLocation

type TONLocation struct {
	// contains filtered or unexported fields
}

The index contributes a location, never a vote or any unchecked output fields.

func LocateTON

func LocateTON(ctx context.Context, n Network, hash string) (TONLocation, error)

Jump to

Keyboard shortcuts

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