Documentation
¶
Index ¶
- Variables
- func GetReqIdCtx(ctx context.Context) string
- func WithRequestId(ctx context.Context, requestID int) context.Context
- type AccountNamedKey
- type BlockIdentifier
- type ChainGetBlockResult
- type ChainGetBlockTransfersResult
- type ChainGetEraInfoResult
- type ChainGetEraSummaryResult
- type ChainGetStateRootHashResult
- type Client
- type ClientInformational
- type ClientPOS
- type ClientTransactional
- type CtxRequestID
- type Handler
- type HttpError
- type IDValue
- type InfoGetChainspecResult
- type InfoGetDeployResult
- type InfoGetPeerResult
- type InfoGetStatusResult
- type InfoGetValidatorChangesResult
- type Method
- type NodeNextUpgrade
- type NodePeer
- type ParamBlockIdentifier
- type ParamDictionaryIdentifier
- type ParamDictionaryIdentifierContractNamedKey
- type ParamDictionaryIdentifierURef
- type ParamGetAccountInfoBalance
- type ParamQueryGlobalState
- type ParamQueryGlobalStateID
- type ParamStateRootHash
- type PurseIdentifier
- type PutDeployRequest
- type PutDeployResult
- type QueryBalanceRequest
- type QueryBalanceResult
- type QueryGlobalStateResult
- type RpcError
- type RpcRequest
- type RpcResponse
- type SpeculativeClient
- type SpeculativeExecParams
- type SpeculativeExecResult
- type StateGetAccountInfo
- type StateGetAuctionInfoResult
- type StateGetBalanceResult
- type StateGetDictionaryResult
- type StateGetItemResult
- type StatusChanges
- type ValidatorChanges
- type ValidatorState
Constants ¶
This section is empty.
Variables ¶
var ( ErrParamsUnmarshalHandler = errors.New("failed to marshal rpc request's params") ErrBuildHttpRequestHandler = errors.New("failed to build http request") ErrProcessHttpRequest = errors.New("failed to sent http request") ErrReadHttpResponseBody = errors.New("failed to read http response body") ErrRpcResponseUnmarshal = errors.New("failed to unmarshal rpc response") )
var ApiVersion = "2.0"
var ErrResultUnmarshal = errors.New("failed to unmarshal rpc result")
Functions ¶
func GetReqIdCtx ¶
Types ¶
type AccountNamedKey ¶ added in v1.4.0
type BlockIdentifier ¶
type ChainGetBlockResult ¶
type ChainGetEraInfoResult ¶
type ChainGetEraInfoResult struct { Version string `json:"api_version"` EraSummary types.EraSummary `json:"era_summary"` }
type ChainGetEraSummaryResult ¶ added in v1.0.0
type ChainGetEraSummaryResult struct { Version string `json:"api_version"` EraSummary types.EraSummary `json:"era_summary"` }
type Client ¶
type Client interface { ClientPOS ClientInformational ClientTransactional }
Client interface represent full RPC client that includes all possible queries.
type ClientInformational ¶
type ClientInformational interface { // GetAccountBalance returns a purse's balance from a network. // The request takes in the formatted representation of a purse URef as a parameter. // If the param stateRootHash is nil, the client will make an additional RPC call to retrieve the latest stateRootHash. GetAccountBalance(ctx context.Context, stateRootHash *string, purseURef string) (StateGetBalanceResult, error) // GetDeploy retrieves a Deploy from a network. It requires a deploy_hash to query the Deploy. GetDeploy(ctx context.Context, hash string) (InfoGetDeployResult, error) // GetDeployFinalizedApproval returns Deploy with the finalized approvals substituted. GetDeployFinalizedApproval(ctx context.Context, hash string) (InfoGetDeployResult, error) // GetDictionaryItem returns an item from a Dictionary. // The address of a stored value is the blake2b hash of the seed URef and the byte representation of the dictionary key. // If the param stateRootHash is nil, the client will make an additional RPC call to retrieve the latest stateRootHash. GetDictionaryItem(ctx context.Context, stateRootHash *string, uref, key string) (StateGetDictionaryResult, error) // GetDictionaryItemByIdentifier returns an item from a Dictionary. // Every dictionary has a seed URef, findable by using a dictionary_identifier. GetDictionaryItemByIdentifier(ctx context.Context, stateRootHash *string, identifier ParamDictionaryIdentifier) (StateGetDictionaryResult, error) // GetStateItem allows to get item from the global state // If the param stateRootHash is nil, the client will make an additional RPC call to retrieve the latest stateRootHash. // Deprecated: use QueryGlobalStateByStateHash instead GetStateItem(ctx context.Context, stateRootHash *string, key string, path []string) (StateGetItemResult, error) // QueryGlobalStateByBlockHash allows for you to query for a value stored under certain keys in global state. QueryGlobalStateByBlockHash(ctx context.Context, blockHash, key string, path []string) (QueryGlobalStateResult, error) // QueryGlobalStateByBlockHeight allows for you to query for a value stored under certain keys in global state. QueryGlobalStateByBlockHeight(ctx context.Context, blockHeight uint64, key string, path []string) (QueryGlobalStateResult, error) // QueryGlobalStateByStateHash allows for you to query for a value stored under certain keys in global state. // If the param stateRootHash is nil, the client will make an additional RPC call to retrieve the latest stateRootHash. QueryGlobalStateByStateHash(ctx context.Context, stateRootHash *string, key string, path []string) (QueryGlobalStateResult, error) // GetAccountInfoByBlochHash returns a JSON representation of an Account from the network. // The blockHash must refer to a Block after the Account's creation, or the method will return an empty response. GetAccountInfoByBlochHash(ctx context.Context, blockHash string, pub keypair.PublicKey) (StateGetAccountInfo, error) // GetAccountInfoByBlochHeight returns a JSON representation of an Account from the network. // The blockHeight must refer to a Block after the Account's creation, or the method will return an empty response. GetAccountInfoByBlochHeight(ctx context.Context, blockHeight uint64, pub keypair.PublicKey) (StateGetAccountInfo, error) // GetBlockLatest returns the latest types.Block from the network. GetBlockLatest(ctx context.Context) (ChainGetBlockResult, error) // GetBlockByHash returns the types.Block from the network the requested block hash. GetBlockByHash(ctx context.Context, hash string) (ChainGetBlockResult, error) // GetBlockByHeight returns the types.Block from the network the requested block height. GetBlockByHeight(ctx context.Context, height uint64) (ChainGetBlockResult, error) // GetBlockTransfersLatest returns all native transfers within a lasted Block from a network. GetBlockTransfersLatest(ctx context.Context) (ChainGetBlockTransfersResult, error) // GetBlockTransfersByHash returns all native transfers within a given Block from a network the requested block hash. GetBlockTransfersByHash(ctx context.Context, blockHash string) (ChainGetBlockTransfersResult, error) // GetBlockTransfersByHeight returns all native transfers within a given Block from a network the requested block height. GetBlockTransfersByHeight(ctx context.Context, height uint64) (ChainGetBlockTransfersResult, error) // GetEraSummaryLatest returns the era summary at a latest Block. GetEraSummaryLatest(ctx context.Context) (ChainGetEraSummaryResult, error) // GetEraSummaryByHash returns the era summary at a Block by hash. GetEraSummaryByHash(ctx context.Context, blockHash string) (ChainGetEraSummaryResult, error) // GetEraSummaryByHeight returns the era summary at a Block by height. GetEraSummaryByHeight(ctx context.Context, height uint64) (ChainGetEraSummaryResult, error) // GetStateRootHashLatest returns a state root hash of the latest Block. GetStateRootHashLatest(ctx context.Context) (ChainGetStateRootHashResult, error) // GetStateRootHashByHash returns a state root hash of the latest Block the requested block hash. GetStateRootHashByHash(ctx context.Context, blockHash string) (ChainGetStateRootHashResult, error) // GetStateRootHashByHeight returns a state root hash of the latest Block the requested block height. GetStateRootHashByHeight(ctx context.Context, height uint64) (ChainGetStateRootHashResult, error) // GetStatus return the current status of a node on a Casper network. // The responses return information specific to the queried node, and as such, will vary. GetStatus(ctx context.Context) (InfoGetStatusResult, error) // GetPeers return a list of peers connected to the node on a Casper network. // The responses return information specific to the queried node, and as such, will vary. GetPeers(ctx context.Context) (InfoGetPeerResult, error) // QueryBalance queries for balances under a given PurseIdentifier QueryBalance(ctx context.Context, identifier PurseIdentifier) (QueryBalanceResult, error) // GetChainspec returns the raw bytes of the chainspec.toml, accounts.toml and global_state.toml files as read at node startup. GetChainspec(ctx context.Context) (InfoGetChainspecResult, error) }
ClientInformational contains methods that return information from a node on a Casper network. The response should be identical, regardless of the node queried, as the information in question is objective and common to all nodes within a network.
type ClientPOS ¶
type ClientPOS interface { // GetAuctionInfoLatest returns the types.ValidatorBid and types.EraValidators from the most recent Block. GetAuctionInfoLatest(ctx context.Context) (StateGetAuctionInfoResult, error) // GetAuctionInfoByHash returns the types.ValidatorBid and types.EraValidators of either a specific Block by hash GetAuctionInfoByHash(ctx context.Context, blockHash string) (StateGetAuctionInfoResult, error) // GetAuctionInfoByHeight returns the types.ValidatorBid and types.EraValidators of either a specific Block by height GetAuctionInfoByHeight(ctx context.Context, height uint64) (StateGetAuctionInfoResult, error) // GetEraInfoLatest returns an EraInfo from the network. // Only the last Block in an era, known as a switch block, will contain an era_summary. // This method return information about the latest block in the chain, it may not be the last block in the era. GetEraInfoLatest(ctx context.Context) (ChainGetEraInfoResult, error) // GetEraInfoByBlockHeight returns an EraInfo from the network. // Only the last Block in an era, known as a switch block, will contain an era_summary. // Querying by block height. GetEraInfoByBlockHeight(ctx context.Context, height uint64) (ChainGetEraInfoResult, error) // GetEraInfoByBlockHash returns an EraInfo from the network. // Only the last Block in an era, known as a switch block, will contain an era_summary. // Querying by block hash. GetEraInfoByBlockHash(ctx context.Context, hash string) (ChainGetEraInfoResult, error) // GetValidatorChangesInfo returns status changes of active validators. Listed changes occurred during the EraId // contained within the response itself. A validator may show more than one change in a single era. GetValidatorChangesInfo(ctx context.Context) (InfoGetValidatorChangesResult, error) }
ClientPOS contains methods pertain to the Proof-of-Stake functionality of a Casper network. They return information related to auctions, bids and validators. This information is necessary for users involved with node operations and validation.
type ClientTransactional ¶
type ClientTransactional interface {
PutDeploy(ctx context.Context, deploy types.Deploy) (PutDeployResult, error)
}
ClientTransactional contains the description of account_put_deploy, the only means by which users can send their compiled Wasm (as part of a Deploy) to a node on a Casper network.
type Handler ¶
type Handler interface {
ProcessCall(ctx context.Context, params RpcRequest) (RpcResponse, error)
}
Handler is responsible to implement interaction with underlying protocol.
type HttpError ¶
func (*HttpError) IsNotFound ¶
type IDValue ¶ added in v1.3.1
type IDValue struct {
// contains filtered or unexported fields
}
func NewIDFromInt ¶ added in v1.3.1
func NewIDFromString ¶ added in v1.3.1
func (*IDValue) MarshalJSON ¶ added in v1.3.1
func (*IDValue) UnmarshalJSON ¶ added in v1.3.1
type InfoGetChainspecResult ¶ added in v1.2.0
type InfoGetChainspecResult struct { ApiVersion string `json:"api_version"` ChainspecBytes struct { ChainspecBytes string `json:"chainspec_bytes,omitempty"` MaybeGenesisAccountsBytes string `json:"maybe_genesis_accounts_bytes,omitempty"` MaybeGlobalStateBytes string `json:"maybe_global_state_bytes,omitempty"` } `json:"chainspec_bytes"` }
type InfoGetDeployResult ¶
type InfoGetPeerResult ¶
type InfoGetStatusResult ¶
type InfoGetStatusResult struct { // The RPC API version. APIVersion string `json:"api_version"` // The compiled node version. BuildVersion string `json:"build_version"` // The chainspec name, used to identify the currently connected network. ChainSpecName string `json:"chainspec_name"` // The minimal info of the last block from the linear chain. LastAddedBlockInfo types.MinimalBlockInfo `json:"last_added_block_info"` // Information about the next scheduled upgrade. NextUpgrade NodeNextUpgrade `json:"next_upgrade,omitempty"` // Node public signing key. OutPublicSigningKey string `json:"our_public_signing_key"` // The list of node ID and network address of each connected peer. Peers []NodePeer `json:"peers"` // The next round length if this node is a validator. RoundLength string `json:"round_length"` // The state root hash used at the start of the current session. StartingStateRootHash string `json:"starting_state_root_hash"` // Time that passed since the node has started. format "2months 20days 22h 3m 21s 512ms" Uptime string `json:"uptime"` // Indicating the node's current operating mode ReactorState string `json:"reactor_state"` // Indicating the time the node last made progress LastProgress types.Timestamp `json:"last_progress"` // Indicating the highest contiguous sequence of the block chain for which the node has complete data AvailableBlockRange struct { Low uint64 `json:"low"` High uint64 `json:"high"` } `json:"available_block_range"` // Indicating the state of the block synchronizer component BlockSync struct { Historical string `json:"historical,omitempty"` Forward string `json:"forward,omitempty"` } `json:"block_sync"` }
type InfoGetValidatorChangesResult ¶ added in v1.0.0
type InfoGetValidatorChangesResult struct { APIVersion string `json:"api_version"` Changes []ValidatorChanges `json:"changes"` }
type Method ¶
type Method string
Method is represented a name of the RPC endpoint
const ( MethodGetDeploy Method = "info_get_deploy" MethodGetStateItem Method = "state_get_item" MethodQueryGlobalState Method = "query_global_state" MethodGetDictionaryItem Method = "state_get_dictionary_item" MethodGetStateBalance Method = "state_get_balance" MethodGetStateAccount Method = "state_get_account_info" MethodGetEraInfo Method = "chain_get_era_info_by_switch_block" MethodGetBlock Method = "chain_get_block" MethodGetBlockTransfers Method = "chain_get_block_transfers" MethodGetEraSummary Method = "chain_get_era_summary" MethodGetAuctionInfo Method = "state_get_auction_info" MethodGetValidatorChanges Method = "info_get_validator_changes" MethodGetStateRootHash Method = "chain_get_state_root_hash" MethodGetStatus Method = "info_get_status" MethodGetPeers Method = "info_get_peers" MethodPutDeploy Method = "account_put_deploy" MethodSpeculativeExec Method = "speculative_exec" MethodQueryBalance Method = "query_balance" MethodInfoGetChainspec Method = "info_get_chainspec" )
type NodeNextUpgrade ¶
type NodeNextUpgrade struct { //The first era to which the associated protocol version applies. ActivationPoint uint64 `json:"activation_point"` // The protocol version of the next upgrade ProtocolVersion string `json:"protocol_version"` }
NodeNextUpgrade contains the information about the next protocol upgrade.
type ParamBlockIdentifier ¶
type ParamBlockIdentifier struct {
BlockIdentifier BlockIdentifier `json:"block_identifier"`
}
func NewParamBlockByHash ¶
func NewParamBlockByHash(hash string) ParamBlockIdentifier
func NewParamBlockByHeight ¶
func NewParamBlockByHeight(height uint64) ParamBlockIdentifier
type ParamDictionaryIdentifier ¶ added in v1.4.0
type ParamDictionaryIdentifier struct { AccountNamedKey *AccountNamedKey `json:"AccountNamedKey,omitempty"` ContractNamedKey *ParamDictionaryIdentifierContractNamedKey `json:"ContractNamedKey,omitempty"` URef *ParamDictionaryIdentifierURef `json:"URef,omitempty"` Dictionary *string `json:"Dictionary,omitempty"` }
type ParamDictionaryIdentifierContractNamedKey ¶ added in v1.4.0
type ParamDictionaryIdentifierURef ¶ added in v1.4.0
type ParamGetAccountInfoBalance ¶ added in v1.1.1
type ParamGetAccountInfoBalance struct { PublicKey keypair.PublicKey `json:"public_key"` ParamBlockIdentifier }
type ParamQueryGlobalState ¶ added in v1.1.1
type ParamQueryGlobalState struct { StateIdentifier ParamQueryGlobalStateID `json:"state_identifier"` Key string `json:"key"` Path []string `json:"path,omitempty"` }
func NewQueryGlobalStateParam ¶ added in v1.0.0
func NewQueryGlobalStateParam(key string, path []string, id ParamQueryGlobalStateID) ParamQueryGlobalState
type ParamQueryGlobalStateID ¶ added in v1.0.0
type ParamStateRootHash ¶
type PurseIdentifier ¶ added in v1.2.0
type PutDeployRequest ¶
type PutDeployResult ¶
type QueryBalanceRequest ¶ added in v1.2.0
type QueryBalanceRequest struct {
PurseIdentifier PurseIdentifier `json:"purse_identifier"`
}
type QueryBalanceResult ¶ added in v1.2.0
type QueryGlobalStateResult ¶ added in v1.0.0
type QueryGlobalStateResult struct { ApiVersion string `json:"api_version"` BlockHeader types.BlockHeader `json:"block_header,omitempty"` StoredValue types.StoredValue `json:"stored_value"` //MerkleProof is a construction created using a merkle trie that allows verification of the associated hashes. MerkleProof json.RawMessage `json:"merkle_proof"` }
type RpcError ¶
type RpcError struct { Code int `json:"code"` Message string `json:"message"` Data json.RawMessage `json:"data,omitempty"` }
type RpcRequest ¶
type RpcRequest struct { // Version of the RPC protocol in use Version string `json:"jsonrpc"` // Id of the RPC request that can be correlated with the equivalent Id in the RPC response ID *IDValue `json:"id,omitempty"` Method Method `json:"method"` Params interface{} `json:"params"` }
RpcRequest is a wrapper struct for an RPC call method that can be serialized to JSON.
func DefaultRpcRequest ¶
func DefaultRpcRequest(method Method, params interface{}) RpcRequest
type RpcResponse ¶
type RpcResponse struct { Version string `json:"jsonrpc"` Id *IDValue `json:"id,omitempty"` Result json.RawMessage `json:"result"` Error *RpcError `json:"error,omitempty"` }
RpcResponse is a wrapper struct for an RPC Response. For a successful response the Result property contains the returned data as a JSON object. If an error occurs Error property contains a description of an error.
type SpeculativeClient ¶ added in v1.2.0
type SpeculativeClient struct {
// contains filtered or unexported fields
}
func NewSpeculativeClient ¶ added in v1.2.0
func NewSpeculativeClient(handler Handler) *SpeculativeClient
func (SpeculativeClient) SpeculativeExec ¶ added in v1.2.0
func (c SpeculativeClient) SpeculativeExec(ctx context.Context, deploy types.Deploy, identifier *BlockIdentifier) (SpeculativeExecResult, error)
type SpeculativeExecParams ¶ added in v1.2.0
type SpeculativeExecParams struct { Deploy types.Deploy `json:"deploy"` BlockIdentifier *BlockIdentifier `json:"block_identifier,omitempty"` }
type SpeculativeExecResult ¶ added in v1.2.0
type SpeculativeExecResult struct { ApiVersion string `json:"api_version"` DeployHash key.Hash `json:"deploy_hash"` ExecutionResult types.ExecutionResultStatus `json:"execution_result"` }
type StateGetAccountInfo ¶ added in v1.0.0
type StateGetAuctionInfoResult ¶
type StateGetAuctionInfoResult struct { Version string `json:"api_version"` AuctionState types.AuctionState `json:"auction_state"` }
type StateGetBalanceResult ¶
type StateGetDictionaryResult ¶ added in v1.0.0
type StateGetDictionaryResult struct { ApiVersion string `json:"api_version"` DictionaryKey string `json:"dictionary_key"` StoredValue types.StoredValue `json:"stored_value"` MerkleProof json.RawMessage `json:"merkle_proof"` }
type StateGetItemResult ¶
type StateGetItemResult struct { StoredValue types.StoredValue `json:"stored_value"` //MerkleProof is a construction created using a merkle trie that allows verification of the associated hashes. MerkleProof json.RawMessage `json:"merkle_proof"` }
type StatusChanges ¶ added in v1.0.0
type StatusChanges struct { EraID uint64 `json:"era_id"` ValidatorState ValidatorState `json:"validator_change"` }
type ValidatorChanges ¶ added in v1.0.0
type ValidatorChanges struct { PublicKey keypair.PublicKey `json:"public_key"` StatusChanges []StatusChanges `json:"status_changes"` }
type ValidatorState ¶ added in v1.0.0
type ValidatorState string
const ( // ValidatorStateAdded means that the validator has been added to the set. ValidatorStateAdded ValidatorState = "Added" // ValidatorStateRemoved means that the validator has been removed from the set. ValidatorStateRemoved ValidatorState = "Removed" // ValidatorStateBanned means that the validator has been banned in the current era. ValidatorStateBanned ValidatorState = "Banned" // ValidatorStateCannotPropose means that the validator cannot propose a Block. ValidatorStateCannotPropose ValidatorState = "CannotPropose" // ValidatorStateSeenAsFaulty means that the validator has performed questionable activity. ValidatorStateSeenAsFaulty ValidatorState = "SeenAsFaulty" )