stellarcore

package
v0.0.0-...-e30ccf4 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2025 License: Apache-2.0, Apache-2.0 Imports: 17 Imported by: 2

Documentation

Overview

Package stellarcore is a client library for communicating with an instance of stellar-core using through the server's HTTP port.

Index

Examples

Constants

View Source
const SetCursorDone = "Done"

SetCursorDone is the success message returned by stellar-core when a cursor update succeeds.

Variables

This section is empty.

Functions

func GenSorobanConfigUpgradeTxAndKey

func GenSorobanConfigUpgradeTxAndKey(
	config GenSorobanConfig, upgradeConfig xdr.ConfigUpgradeSet) ([]xdr.TransactionEnvelope, xdr.ConfigUpgradeSetKey, error)

Types

type Client

type Client struct {
	// HTTP is the client to use when communicating with stellar-core. If nil,
	// http.DefaultClient will be used.
	HTTP HTTP

	// URL of Stellar Core server to connect.
	URL string
}

Client represents a client that is capable of communicating with a stellar-core server using HTTP

func (*Client) GetLedgerEntries

func (c *Client) GetLedgerEntries(ctx context.Context, ledgerSeq uint32, keys ...xdr.LedgerKey) (proto.GetLedgerEntryResponse, error)

func (*Client) GetLedgerEntryRaw

func (c *Client) GetLedgerEntryRaw(ctx context.Context, ledgerSeq uint32, keys ...xdr.LedgerKey) (proto.GetLedgerEntryRawResponse, error)

func (*Client) Info

func (c *Client) Info(ctx context.Context) (resp *proto.InfoResponse, err error)

Info calls the `info` command on the connected stellar core and returns the provided response

Example
client := &Client{URL: "http://localhost:11626"}

info, err := client.Info(context.Background())

if err != nil {
	panic(err)
}

fmt.Printf("synced: %v", info.IsSynced())
Output:

func (*Client) ManualClose

func (c *Client) ManualClose(ctx context.Context) (err error)

ManualClose closes a ledger when Core is running in `MANUAL_CLOSE` mode

func (*Client) SetCursor

func (c *Client) SetCursor(ctx context.Context, id string, cursor int32) (err error)

SetCursor calls the `setcursor` command on the connected stellar core

func (*Client) SubmitTransaction

func (c *Client) SubmitTransaction(ctx context.Context, envelope string) (resp *proto.TXResponse, err error)

SubmitTransaction calls the `tx` command on the connected stellar core with the provided envelope

func (*Client) Upgrade deprecated

func (c *Client) Upgrade(ctx context.Context, version int) (err error)

Upgrade upgrades the protocol version running on the stellar core instance

Deprecated: use UpgradeProtocol instead

func (*Client) UpgradeProtocol

func (c *Client) UpgradeProtocol(ctx context.Context, protocolVersion int, at time.Time) (err error)

UpgradeProtocol upgrades the protocol version running on the stellar core instance

func (*Client) UpgradeSorobanConfig

func (c *Client) UpgradeSorobanConfig(ctx context.Context, configKey xdr.ConfigUpgradeSetKey, at time.Time) error

UpgradeSorobanConfig upgrades the Soroban configuration to that indicated by the supplied ConfigUpgradeSetKey at the specified time

func (*Client) UpgradeSorobanTxSetSize

func (c *Client) UpgradeSorobanTxSetSize(ctx context.Context, maxTxSetSize uint32, at time.Time) error

UpgradeSorobanTxSetSize upgrades the maximum number of transactions per ledger

func (*Client) UpgradeTxSetSize

func (c *Client) UpgradeTxSetSize(ctx context.Context, maxTxSetSize uint32, at time.Time) error

UpgradeTxSetSize upgrades the maximum number of transactions per ledger

func (*Client) WaitForNetworkSync

func (c *Client) WaitForNetworkSync(ctx context.Context) error

WaitForNetworkSync continually polls the connected stellar-core until it receives a response that indicated the node has synced with the network

type ClientWithMetrics

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

func NewClientWithMetrics

func NewClientWithMetrics(client Client, registry *prometheus.Registry, prometheusSubsystem string) ClientWithMetrics

func (ClientWithMetrics) SubmitTx

func (c ClientWithMetrics) SubmitTx(ctx context.Context, rawTx string) (*proto.TXResponse, error)

type GenSorobanConfig

type GenSorobanConfig struct {
	BaseSeqNum        uint32
	NetworkPassphrase string
	SigningKey        *keypair.Full
	// looks for `stellar-core` in the system PATH if empty
	StellarCorePath string
}

type HTTP

type HTTP interface {
	Do(req *http.Request) (*http.Response, error)
}

HTTP represents the http client that a stellarcore client uses to make http requests.

Jump to

Keyboard shortcuts

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