state

package
v0.3.0-rc1 Latest Latest
Warning

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

Go to latest
Published: May 25, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package state provides a structure for celestia-node's ability to access state-relevant information from as well as submit transactions/messages to the celestia network.

This package contains one main interface, `Accessor`, that defines the methods available for both accessing and updating state on the celestia network.

`Accessor` will contain three different implementations:

  1. Implementation over a gRPC connection with a celestia-core node called `CoreAccess`.
  2. Implementation over a libp2p stream with a state-providing node.
  3. Implementation over a local running instance of the celestia-application (this feature will be implemented in *Full* nodes).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Accessor

type Accessor interface {
	// Start starts the state Accessor.
	Start(context.Context) error
	// Stop stops the state Accessor.
	Stop(context.Context) error

	// SubmitPayForData builds, signs and submits a PayForData transaction.
	SubmitPayForData(ctx context.Context, nID namespace.ID, data []byte, gasLim uint64) (*TxResponse, error)

	// Balance retrieves the Celestia coin balance
	// for the node's account/signer.
	Balance(ctx context.Context) (*Balance, error)
	// BalanceForAddress retrieves the Celestia coin balance
	// for the given types.AccAddress.
	BalanceForAddress(ctx context.Context, addr Address) (*Balance, error)
	// SubmitTx submits the given transaction/message to the
	// Celestia network and blocks until the tx is included in
	// a block.
	SubmitTx(ctx context.Context, tx Tx) (*TxResponse, error)
}

Accessor represents the behaviors necessary for a user to query for state-related information and submit transactions/ messages to the Celestia network.

type Address

type Address = sdk.Address

Address is an alias to the Address type from Cosmos-SDK.

type Balance

type Balance = sdk.Coin

Balance is an alias to the Coin type from Cosmos-SDK.

type CoreAccessor

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

CoreAccessor implements Accessor over an RPC connection with a celestia-core node.

func NewCoreAccessor

func NewCoreAccessor(
	signer *apptypes.KeyringSigner,
	endpoint string,
) *CoreAccessor

NewCoreAccessor dials the given celestia-core endpoint and constructs and returns a new CoreAccessor with the active connection.

func (*CoreAccessor) Balance

func (ca *CoreAccessor) Balance(ctx context.Context) (*Balance, error)

func (*CoreAccessor) BalanceForAddress

func (ca *CoreAccessor) BalanceForAddress(ctx context.Context, addr Address) (*Balance, error)

func (*CoreAccessor) Start

func (ca *CoreAccessor) Start(ctx context.Context) error

func (*CoreAccessor) Stop

func (ca *CoreAccessor) Stop(context.Context) error

func (*CoreAccessor) SubmitPayForData

func (ca *CoreAccessor) SubmitPayForData(
	ctx context.Context,
	nID namespace.ID,
	data []byte,
	gasLim uint64,
) (*TxResponse, error)

func (*CoreAccessor) SubmitTx

func (ca *CoreAccessor) SubmitTx(ctx context.Context, tx Tx) (*TxResponse, error)

func (*CoreAccessor) SubmitTxWithBroadcastMode

func (ca *CoreAccessor) SubmitTxWithBroadcastMode(
	ctx context.Context,
	tx Tx,
	mode sdk_tx.BroadcastMode,
) (*TxResponse, error)

type Service

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

Service can access state-related information via the given Accessor.

func NewService

func NewService(accessor Accessor) *Service

NewService constructs a new state Service.

func (*Service) Balance

func (s *Service) Balance(ctx context.Context) (*Balance, error)

func (*Service) BalanceForAddress

func (s *Service) BalanceForAddress(ctx context.Context, addr Address) (*Balance, error)

func (*Service) SubmitPayForData

func (s *Service) SubmitPayForData(
	ctx context.Context,
	nID namespace.ID,
	data []byte,
	gasLim uint64,
) (*TxResponse, error)

func (*Service) SubmitTx

func (s *Service) SubmitTx(ctx context.Context, tx Tx) (*TxResponse, error)

type Tx

type Tx = coretypes.Tx

Tx is an alias to the Tx type from celestia-core.

type TxResponse

type TxResponse = sdk.TxResponse

TxResponse is an alias to the TxResponse type from Cosmos-SDK.

Jump to

Keyboard shortcuts

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