jsonrpc

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ErrCodeParse is a reserved JSON-RPC error code
	ErrCodeParse = -32700
	// ErrCodeInvalidRequest is a reserved JSON-RPC error code
	ErrCodeInvalidRequest = -32600
	// ErrCodeMethodNotFound is a reserved JSON-RPC error code
	ErrCodeMethodNotFound = -32601
	// ErrCodeInvalidParams is a reserved JSON-RPC error code
	ErrCodeInvalidParams = -32602
	// ErrCodeInternal is a reserved JSON-RPC error code
	ErrCodeInternal = -32603
)

Variables

View Source
var (

	// ErrParse represents a JSON-RPC error indicating a problem with parsing the JSON request payload.
	ErrParse = &jsonRPCError{Code: ErrCodeParse, Message: "Parse error"}

	// ErrInvalidRequest represents a JSON-RPC error indicating an invalid JSON request payload.
	ErrInvalidRequest = &jsonRPCError{Code: ErrCodeInvalidRequest, Message: "Invalid request"}

	// ErrMethodNotFound represents a JSON-RPC error indicating that the requested method could not be found.
	ErrMethodNotFound = &jsonRPCError{Code: ErrCodeMethodNotFound, Message: "Method not found"}

	// ErrInvalidParams represents a JSON-RPC error indicating invalid parameters in the request.
	ErrInvalidParams = &jsonRPCError{Code: ErrCodeInvalidParams, Message: "Invalid params"}

	// ErrInternal represents a JSON-RPC error indicating an unspecified internal error within the server.
	ErrInternal = &jsonRPCError{Code: ErrCodeInternal, Message: "Internal error"}
)

Functions

This section is empty.

Types

type Client

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

Client defines JSON-RPC proxy client of execution API.

func NewClient

func NewClient() *Client

NewClient creates new proxy client with default config.

func (*Client) ExecuteTxs

func (c *Client) ExecuteTxs(ctx context.Context, txs []types.Tx, blockHeight uint64, timestamp time.Time, prevStateRoot types.Hash) (types.Hash, uint64, error)

ExecuteTxs executes a set of transactions to produce a new block header.

func (*Client) GetTxs

func (c *Client) GetTxs(ctx context.Context) ([]types.Tx, error)

GetTxs retrieves all available transactions from the execution client's mempool.

func (*Client) InitChain

func (c *Client) InitChain(ctx context.Context, genesisTime time.Time, initialHeight uint64, chainID string) (types.Hash, uint64, error)

InitChain initializes the blockchain with genesis information.

func (*Client) SetConfig

func (c *Client) SetConfig(config *Config)

SetConfig updates the client's configuration with the provided config.

func (*Client) SetFinal

func (c *Client) SetFinal(ctx context.Context, blockHeight uint64) error

SetFinal marks a block at the given height as final.

func (*Client) Start

func (c *Client) Start(endpoint string) error

Start is used to start the client.

func (*Client) Stop

func (c *Client) Stop() error

Stop method is used to stop the client.

type Config

type Config struct {
	DefaultTimeout time.Duration
	MaxRequestSize int64
}

Config represents configuration settings for server/client.

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns Config struct initialized with default settings.

type Server

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

Server defines JSON-RPC proxy server for execution API.

func NewServer

func NewServer(exec execution.Executor, config *Config) *Server

NewServer initializes and returns a new Server instance with the given execution interface and configuration.

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

Jump to

Keyboard shortcuts

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