Documentation ¶
Index ¶
- Variables
- func Decode(body []byte, target interface{}) error
- func DecodeScaleUnmarshal(body []byte, target any) error
- func EpochLength(ctx context.Context, rpcPort string) (epochLength uint64, err error)
- func GetBlock(ctx context.Context, rpcPort string, hash common.Hash) (block *types.Block, err error)
- func GetBlockHash(ctx context.Context, rpcPort, num string) (hash common.Hash, err error)
- func GetChainHead(ctx context.Context, rpcPort string) (header *types.Header, err error)
- func GetFinalizedHead(ctx context.Context, rpcPort string) (hash common.Hash, err error)
- func GetFinalizedHeadByRound(ctx context.Context, rpcPort string, round uint64) (hash common.Hash, err error)
- func GetHealth(ctx context.Context, address string) (health modules.SystemHealthResponse, err error)
- func GetPeers(ctx context.Context, rpcPort string) (peers []common.PeerInfo, err error)
- func NewEndpoint(port string) string
- func PauseBABE(ctx context.Context, rpcPort string) error
- func Post(ctx context.Context, endpoint, method, params string) (data []byte, err error)
- func SlotDuration(ctx context.Context, rpcPort string) (slotDuration time.Duration, err error)
- type Error
- type ServerResponse
Constants ¶
This section is empty.
Variables ¶
var ( ErrResponseVersion = errors.New("unexpected response version received") ErrResponseError = errors.New("response error received") )
Functions ¶
func Decode ¶
Decode decodes []body into the target interface. It assumes that the response.Result is an optional JSON-encoded value.
func DecodeScaleUnmarshal ¶ added in v0.8.0
DecodeScaleUnmarshal decodes []body into the result. It assumes that the response.Result is a SCALE-encoded value.
func EpochLength ¶
EpochLength Calls dev endpoint for epoch length
func GetBlock ¶
func GetBlock(ctx context.Context, rpcPort string, hash common.Hash) ( block *types.Block, err error)
GetBlock calls the endpoint chain_getBlock
func GetBlockHash ¶
GetBlockHash calls the endpoint chain_getBlockHash to get the latest chain head. It will block until a response is received or the context gets canceled.
func GetChainHead ¶
GetChainHead calls the endpoint chain_getHeader to get the latest chain head
func GetFinalizedHead ¶
GetFinalizedHead calls the endpoint chain_getFinalizedHead to get the latest finalised head
func GetFinalizedHeadByRound ¶
func GetFinalizedHeadByRound(ctx context.Context, rpcPort string, round uint64) ( hash common.Hash, err error)
GetFinalizedHeadByRound calls the endpoint chain_getFinalizedHeadByRound to get the finalised head at a given round TODO: add setID, hard-coded at 1 for now
func GetHealth ¶
func GetHealth(ctx context.Context, address string) ( health modules.SystemHealthResponse, err error)
GetHealth sends an RPC request to `system_health`.
Types ¶
type Error ¶
type Error struct { Message string `json:"message"` ErrorCode int `json:"code"` Data map[string]interface{} `json:"data"` }
Error is a struct that holds the error message and the error code for a error
type ServerResponse ¶
type ServerResponse struct { // JSON-RPC Version Version string `json:"jsonrpc"` // Method name called Method string `json:"method"` // Resulting values Result json.RawMessage `json:"result"` // Params values including results Params json.RawMessage `json:"params"` // Any generated errors Error *Error `json:"error"` Subscription *json.RawMessage `json:"subscription"` // Request id ID *json.RawMessage `json:"id"` }
ServerResponse wraps the RPC response