akash

package
v2.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2026 License: Apache-2.0 Imports: 53 Imported by: ? 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

Overview

Package akash is the reporter's only path to Akash: height-pinned state reads, the height tracker, listing and the audit cursor, and the CometBFT calls that broadcast and look up transactions (spec §5.3).

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrRecordNotFound reports a transfer the node does not have at the read height.
	ErrRecordNotFound = errors.New("Sink record not found") //nolint:staticcheck // verbatim TS text
	// ErrAccountNotFound reports a reporter address that has no account yet.
	ErrAccountNotFound = errors.New("reporter account not found")
)

Functions

func WithStop

func WithStop(ctx, stop context.Context) context.Context

WithStop returns ctx under which a query still waiting for a concurrency permit gives up once stop ends. Such a call is not in flight yet, so shutdown cancels it; a call that holds a permit runs under ctx and the request timeout only, and finishes or times out (spec §5.7).

Types

type AuditCursor

type AuditCursor struct {
	Kind   CursorKind
	Key    []byte
	LastID sinkid.ID
}

AuditCursor is where the chronological audit resumes: the server's opaque page key and the last ID returned.

type AuditPage

type AuditPage struct {
	IDs     []sinkid.ID
	Cursor  *AuditCursor
	HasMore bool
}

AuditPage is one page of the chronological audit.

type BroadcastResult

type BroadcastResult struct {
	Code      uint32
	Codespace string
	Log       string
	Hash      []byte
	InCache   bool
}

BroadcastResult is a broadcast_tx_sync answer. InCache means identical bytes were already pending or included; such a result has no CheckTx outcome, and Hash is computed locally.

type Client

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

Client reads one Akash node through gRPC and CometBFT RPC, or CometBFT RPC alone for legacy JSON. It is safe for concurrent use.

func Dial

func Dial(ctx context.Context, opts Options) (*Client, error)

Dial connects to the node's CometBFT RPC and gRPC endpoints and refuses them unless they are one node. ABCI mode uses only the CometBFT endpoint for legacy JSON.

func (*Client) AccountNumber

func (c *Client) AccountNumber(ctx context.Context, addr sdk.AccAddress) (uint64, error)

AccountNumber reads the account number of addr at the node's latest state.

func (*Client) AccountPublicKey

func (c *Client) AccountPublicKey(ctx context.Context, addr sdk.AccAddress) (cryptotypes.PubKey, error)

AccountPublicKey reads and validates the reporter's on-chain secp256k1 public key. It pins the lookup to the current validated snapshot. Preview and offline check never call it.

func (*Client) Audit

func (c *Client) Audit(ctx context.Context, height int64, after *AuditCursor, limit int) (AuditPage, error)

Audit reads one page of the chronological history at height from after, which is nil at the start, as discoverTransfers does.

func (*Client) BlockMaxGas

func (c *Client) BlockMaxGas(ctx context.Context) (int64, error)

BlockMaxGas reads the consensus block max gas at the node's latest state; -1 or 0 means unlimited.

func (*Client) BroadcastSync

func (c *Client) BroadcastSync(ctx context.Context, txBytes []byte) (BroadcastResult, error)

BroadcastSync submits txBytes with broadcast_tx_sync. A CheckTx rejection is a result with a non-zero Code; a transport or other JSON-RPC failure is an error.

func (*Client) Close

func (c *Client) Close() error

Close releases the gRPC connection and idle CometBFT connections.

func (*Client) Latest

func (c *Client) Latest(ctx context.Context) (*State, error)

Latest returns the latest snapshot. At most one refresh runs per MinRefresh: concurrent callers share an in-flight refresh, and its snapshot or error is reused until MinRefresh has passed since it started. A snapshot may be lower than an earlier one, for example from a load-balanced node; safety does not depend on height order.

func (*Client) ListOpen

func (c *Client) ListOpen(ctx context.Context, height int64, pageSize int) ([]sinkid.ID, error)

ListOpen lists every disputed, refund-pending, void-requested and transfer-pending transfer at height. The four listings run concurrently, each paging sequentially, and merge in that order; an ID listed twice keeps its first position.

func (*Client) Simulate

func (c *Client) Simulate(ctx context.Context, txBytes []byte) (uint64, error)

Simulate runs txBytes against the node's latest state and returns the gas it used. A failure keeps the node's message, which names the failing message index.

func (*Client) Transfer

func (c *Client) Transfer(ctx context.Context, height int64, id sinkid.ID) (sinkv1.TransferState, error)

Transfer reads one transfer at height. A transfer the node does not have is ErrRecordNotFound; any other failure means the node is unavailable.

func (*Client) Tx

func (c *Client) Tx(ctx context.Context, hash []byte) (*TxResult, error)

Tx looks up an included transaction by hash; it returns nil and no error when the node does not have it.

func (*Client) TxIndexEnabled

func (c *Client) TxIndexEnabled() bool

TxIndexEnabled reports whether the node indexed transactions when Dial read its status.

func (*Client) TxIndexedBelow

func (c *Client) TxIndexedBelow(ctx context.Context, hash []byte, height int64) (*TxResult, bool, error)

TxIndexedBelow looks up an included transaction by hash, as Tx does, and reports whether the answering node had indexed every block below height: CometBFT indexes a block's transactions before the next block's events, so it had once block height is in its block index, unless it failed to write a block, which it logs and does not retry. One batched request asks the block index first, so a node, or a proxy that passes the batch on whole, answers both and looks up the hash with an index at least that far along.

type CursorKind

type CursorKind int

CursorKind is how the audit resumes.

const (
	// CursorNext resumes at the server's next page.
	CursorNext CursorKind = iota + 1
	// CursorTail replays the last page, skipping IDs up to LastID, to find transfers added since.
	CursorTail
)

type Options

type Options struct {
	// Node is the CometBFT RPC URL.
	Node string
	// ABCI selects generated queries over the single Comet endpoint for legacy JSON.
	ABCI bool
	// GRPCAddr is the gRPC host:port of the same node.
	GRPCAddr string
	// GRPCInsecure uses plaintext gRPC for a non-loopback address; loopback always uses plaintext.
	GRPCInsecure bool
	ChainID      string
	// MaxAge is the oldest block age a snapshot accepts.
	MaxAge time.Duration
	// RequestTimeout bounds each request; zero means no bound.
	RequestTimeout time.Duration
	// Concurrency limits concurrent queries and sizes the CometBFT connection pool.
	Concurrency int
	// MinRefresh is the shortest interval between tracker refreshes; zero means one second.
	MinRefresh time.Duration
	// Clock judges block freshness and refresh intervals; nil means the system clock.
	Clock   clock.Clock
	Metrics *metrics.Metrics
}

Options configures a Client.

type State

type State struct {
	Height      int64
	Time        time.Time
	Params      sinkv1.Params
	Policy      sinkv1.ReporterPolicy
	RefundUsage sinkv1.EpochUsage
	SendUsage   sinkv1.EpochUsage
	Totals      sinkv1.Totals
	Epoch       uint64
	RefundHead  *sinkid.ID
}

State is an immutable snapshot of the sink module at one committed height. Callers share it and must not change it.

type TxResult

type TxResult struct {
	Height    int64
	Code      uint32
	Codespace string
	Log       string
}

TxResult is the delivery result of an included transaction.

Jump to

Keyboard shortcuts

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