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 ¶
- Variables
- func WithStop(ctx, stop context.Context) context.Context
- type AuditCursor
- type AuditPage
- type BroadcastResult
- type Client
- func (c *Client) AccountNumber(ctx context.Context, addr sdk.AccAddress) (uint64, error)
- func (c *Client) AccountPublicKey(ctx context.Context, addr sdk.AccAddress) (cryptotypes.PubKey, error)
- func (c *Client) Audit(ctx context.Context, height int64, after *AuditCursor, limit int) (AuditPage, error)
- func (c *Client) BlockMaxGas(ctx context.Context) (int64, error)
- func (c *Client) BroadcastSync(ctx context.Context, txBytes []byte) (BroadcastResult, error)
- func (c *Client) Close() error
- func (c *Client) Latest(ctx context.Context) (*State, error)
- func (c *Client) ListOpen(ctx context.Context, height int64, pageSize int) ([]sinkid.ID, error)
- func (c *Client) Simulate(ctx context.Context, txBytes []byte) (uint64, error)
- func (c *Client) Transfer(ctx context.Context, height int64, id sinkid.ID) (sinkv1.TransferState, error)
- func (c *Client) Tx(ctx context.Context, hash []byte) (*TxResult, error)
- func (c *Client) TxIndexEnabled() bool
- func (c *Client) TxIndexedBelow(ctx context.Context, hash []byte, height int64) (*TxResult, bool, error)
- type CursorKind
- type Options
- type State
- type TxResult
Constants ¶
This section is empty.
Variables ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
BlockMaxGas reads the consensus block max gas at the node's latest state; -1 or 0 means unlimited.
func (*Client) BroadcastSync ¶
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) Latest ¶
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 ¶
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 ¶
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 ¶
Tx looks up an included transaction by hash; it returns nil and no error when the node does not have it.
func (*Client) TxIndexEnabled ¶
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.