chain

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Chain

type Chain interface {
	types.ChainService

	ID() string
	Config() *config.TOMLConfig
	TxManager() *txm.StellarTxm
	KeyStore() core.Keystore
	GetClient(ctx context.Context) (RPCClient, error)
}

Chain is the Stellar chain service interface.

func NewChain

func NewChain(cfg *config.TOMLConfig, opts Opts, chainInfo chainsel.StellarChain) (Chain, error)
type Head struct {
	Sequence uint32
}

Head is the multinode head for Stellar. Stellar ledgers are final at close (SCP gives deterministic finality, no reorgs), so there is a single head notion: the latest closed ledger is also the finalized ledger. Difficulty/total-difficulty are PoW concepts and are always nil.

func (*Head) BlockDifficulty added in v0.0.3

func (h *Head) BlockDifficulty() *big.Int

func (*Head) BlockNumber added in v0.0.3

func (h *Head) BlockNumber() int64

func (*Head) GetTotalDifficulty added in v0.0.3

func (h *Head) GetTotalDifficulty() *big.Int

func (*Head) IsValid added in v0.0.3

func (h *Head) IsValid() bool

type MultiNodeClient added in v0.0.3

type MultiNodeClient struct {
	*multinode.RPCClientBase[*Head]

	SorobanClient
	// contains filtered or unexported fields
}

MultiNodeClient embeds *multinode.RPCClientBase, which supplies the head/finalized-head subscriptions (via polling), subscription bookkeeping.

func NewMultiNodeClient added in v0.0.3

func NewMultiNodeClient(
	url string,
	cfg multinode.RPCClientBaseConfig,
	requestTimeout time.Duration,
	lggr logger.Logger,
	rpcMetrics frameworkmetrics.RPCClientMetrics,
) *MultiNodeClient

NewMultiNodeClient builds an adapter around the Soroban RPC at url. cfg supplies the head/finalized poll intervals consumed by RPCClientBase.

func (*MultiNodeClient) ChainID added in v0.0.3

ChainID returns the hex-encoded Stellar network ID (SHA-256 of the network passphrase), which matches the chain-selectors ChainID form used in config, so node chain-ID verification can be enabled.

func (*MultiNodeClient) ClientVersion added in v0.0.3

func (c *MultiNodeClient) ClientVersion(ctx context.Context) (string, error)

ClientVersion doubles as the periodic liveness probe; it returns an error when the RPC is unreachable, which the node lifecycle treats as a health failure.

func (*MultiNodeClient) Close added in v0.0.3

func (c *MultiNodeClient) Close()

Close tears down the framework subscriptions and the underlying SDK client. It is defined explicitly to resolve the ambiguity between RPCClientBase.Close() and SorobanClient.Close().

func (*MultiNodeClient) Dial added in v0.0.3

func (c *MultiNodeClient) Dial(ctx context.Context) error

Dial validates reachability of the endpoint. The SDK client is HTTP and does not hold a persistent connection, so a successful health probe stands in for a dial handshake. A node that responds but reports a non-healthy status is rejected so it is not added to the pool.

func (*MultiNodeClient) IsSyncing added in v0.0.3

func (c *MultiNodeClient) IsSyncing(_ context.Context) (bool, error)

IsSyncing is always false: Stellar RPC does not expose a backfill/sync state that blocks reads, and lagging nodes are caught by head-based out-of-sync detection instead.

type Opts

type Opts struct {
	Logger   logger.Logger
	KeyStore core.Keystore
}

Opts are the external dependencies required to construct a Chain.

func (*Opts) Validate

func (o *Opts) Validate() error

type RPCClient

RPCClient is the subset of the Stellar Soroban JSON-RPC client used across the Stellar relayer (chain + per-component callers). It mirrors the public surface of *rpcclient.Client so production wiring passes the SDK type unchanged and tests can inject mocks. Connection lifecycle is owned by the multinode pool, so this interface does not expose Close.

type SorobanClient added in v0.0.3

type SorobanClient interface {
	RPCClient
	GetHealth(ctx context.Context) (protocolrpc.GetHealthResponse, error)
	GetNetwork(ctx context.Context) (protocolrpc.GetNetworkResponse, error)
	GetVersionInfo(ctx context.Context) (protocolrpc.GetVersionInfoResponse, error)
	Close() error
}

SorobanClient is the subset of the Stellar SDK rpcclient.Client used by MultiNodeClient: the domain RPCClient surface plus the health/network/version probes the multinode node lifecycle needs, plus Close. Holding it as an interface keeps the adapter unit-testable; *rpcclient.Client satisfies it.

Jump to

Keyboard shortcuts

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