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:
- Implementation over a gRPC connection with a celestia-core node called `CoreAccess`.
- Implementation over a libp2p stream with a state-providing node.
- Implementation over a local running instance of the celestia-application (this feature will be implemented in *Full* nodes).
Index ¶
- type Accessor
- type Address
- type Balance
- type CoreAccessor
- func (ca *CoreAccessor) Balance(ctx context.Context) (*Balance, error)
- func (ca *CoreAccessor) BalanceForAddress(ctx context.Context, addr Address) (*Balance, error)
- func (ca *CoreAccessor) BeginRedelegate(ctx context.Context, srcValAddr, dstValAddr Address, amount Int, gasLim uint64) (*TxResponse, error)
- func (ca *CoreAccessor) CancelUnbondingDelegation(ctx context.Context, valAddr Address, amount, height Int, gasLim uint64) (*TxResponse, error)
- func (ca *CoreAccessor) Delegate(ctx context.Context, delAddr Address, amount Int, gasLim uint64) (*TxResponse, error)
- func (ca *CoreAccessor) Start(ctx context.Context) error
- func (ca *CoreAccessor) Stop(context.Context) error
- func (ca *CoreAccessor) SubmitPayForData(ctx context.Context, nID namespace.ID, data []byte, gasLim uint64) (*TxResponse, error)
- func (ca *CoreAccessor) SubmitTx(ctx context.Context, tx Tx) (*TxResponse, error)
- func (ca *CoreAccessor) SubmitTxWithBroadcastMode(ctx context.Context, tx Tx, mode sdktx.BroadcastMode) (*TxResponse, error)
- func (ca *CoreAccessor) Transfer(ctx context.Context, addr Address, amount Int, gasLim uint64) (*TxResponse, error)
- func (ca *CoreAccessor) Undelegate(ctx context.Context, delAddr Address, amount Int, gasLim uint64) (*TxResponse, error)
- type Int
- type Service
- func (s *Service) Balance(ctx context.Context) (*Balance, error)
- func (s *Service) BalanceForAddress(ctx context.Context, addr Address) (*Balance, error)
- func (s *Service) BeginRedelegate(ctx context.Context, srcValAddr, dstValAddr Address, amount Int, gasLim uint64) (*TxResponse, error)
- func (s *Service) CancelUnbondingDelegation(ctx context.Context, valAddr Address, amount, height Int, gasLim uint64) (*TxResponse, error)
- func (s *Service) Delegate(ctx context.Context, delAddr Address, amount Int, gasLim uint64) (*TxResponse, error)
- func (s *Service) IsStopped() bool
- func (s *Service) Start(context.Context) error
- func (s *Service) Stop(context.Context) error
- func (s *Service) SubmitPayForData(ctx context.Context, nID namespace.ID, data []byte, gasLim uint64) (*TxResponse, error)
- func (s *Service) SubmitTx(ctx context.Context, tx Tx) (*TxResponse, error)
- func (s *Service) Transfer(ctx context.Context, to Address, amount Int, gasLimit uint64) (*TxResponse, error)
- func (s *Service) Undelegate(ctx context.Context, delAddr Address, amount Int, gasLim uint64) (*TxResponse, error)
- type Tx
- type TxResponse
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
// Balance retrieves the Celestia coin balance for the node's account/signer
// and verifies it against the corresponding block's AppHash.
Balance(ctx context.Context) (*Balance, error)
// BalanceForAddress retrieves the Celestia coin balance for the given address and verifies
// the returned balance against the corresponding block's AppHash.
//
// NOTE: the balance returned is the balance reported by the block right before
// the node's current head (head-1). This is due to the fact that for block N, the block's
// `AppHash` is the result of applying the previous block's transaction list.
BalanceForAddress(ctx context.Context, addr Address) (*Balance, error)
// Transfer sends the given amount of coins from default wallet of the node to the given account address.
Transfer(ctx context.Context, to types.Address, amount math.Int, gasLimit uint64) (*TxResponse, 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)
// SubmitPayForData builds, signs and submits a PayForData transaction.
SubmitPayForData(ctx context.Context, nID namespace.ID, data []byte, gasLim uint64) (*TxResponse, error)
// CancelUnbondingDelegation cancels a user's pending undelegation from a validator.
CancelUnbondingDelegation(ctx context.Context, valAddr Address, amount, height Int, gasLim uint64) (*TxResponse, error)
// BeginRedelegate sends a user's delegated tokens to a new validator for redelegation.
BeginRedelegate(ctx context.Context, srcValAddr, dstValAddr Address, amount Int, gasLim uint64) (*TxResponse, error)
// Undelegate undelegates a user's delegated tokens, unbonding them from the current validator.
Undelegate(ctx context.Context, delAddr Address, amount Int, gasLim uint64) (*TxResponse, error)
// Delegate sends a user's liquid tokens to a validator for delegation.
Delegate(ctx context.Context, delAddr Address, amount Int, gasLim uint64) (*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 CoreAccessor ¶
type CoreAccessor struct {
// contains filtered or unexported fields
}
CoreAccessor implements Accessor over a gRPC connection with a celestia-core node.
func NewCoreAccessor ¶
func NewCoreAccessor( signer *apptypes.KeyringSigner, getter header.Getter, coreIP, rpcPort string, grpcPort 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 (*CoreAccessor) BeginRedelegate ¶
func (ca *CoreAccessor) BeginRedelegate( ctx context.Context, srcValAddr, dstValAddr Address, amount Int, gasLim uint64, ) (*TxResponse, error)
func (*CoreAccessor) CancelUnbondingDelegation ¶
func (ca *CoreAccessor) CancelUnbondingDelegation( ctx context.Context, valAddr Address, amount, height Int, gasLim uint64, ) (*TxResponse, error)
func (*CoreAccessor) Delegate ¶
func (ca *CoreAccessor) Delegate( ctx context.Context, delAddr Address, amount Int, gasLim uint64, ) (*TxResponse, 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 sdktx.BroadcastMode, ) (*TxResponse, error)
func (*CoreAccessor) Transfer ¶
func (ca *CoreAccessor) Transfer( ctx context.Context, addr Address, amount Int, gasLim uint64, ) (*TxResponse, error)
func (*CoreAccessor) Undelegate ¶
func (ca *CoreAccessor) Undelegate( ctx context.Context, delAddr Address, amount Int, gasLim uint64, ) (*TxResponse, error)
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service can access state-related information via the given Accessor.
func NewService ¶
NewService constructs a new state Service.
func (*Service) BalanceForAddress ¶
func (*Service) BeginRedelegate ¶
func (*Service) CancelUnbondingDelegation ¶
func (*Service) SubmitPayForData ¶
func (*Service) Undelegate ¶
type TxResponse ¶
type TxResponse = sdk.TxResponse
TxResponse is an alias to the TxResponse type from Cosmos-SDK.