grpc

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2025 License: Apache-2.0 Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewServer

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

NewServer creates a new ExecutionService gRPC server with the given execution client and configuration.

Types

type Client

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

Client defines gRPC proxy client

func NewClient

func NewClient() *Client

NewClient creates a new instance of Client with default configuration.

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 sets the configuration for the Client instance.

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(target string, opts ...grpc.DialOption) error

Start initializes the Client by creating a new gRPC connection and storing the ExecutionServiceClient instance.

func (*Client) Stop

func (c *Client) Stop() error

Stop stops the client by closing the underlying gRPC connection if it exists.

type Config

type Config struct {
	JWTSecret      []byte
	DefaultTimeout time.Duration
	MaxRequestSize int
}

Config holds configuration settings for the gRPC proxy.

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns a Config instance populated with default settings.

type Server

type Server struct {
	pb.UnimplementedExecutionServiceServer
	// contains filtered or unexported fields
}

Server defines a gRPC proxy server

func (*Server) ExecuteTxs

func (s *Server) ExecuteTxs(ctx context.Context, req *pb.ExecuteTxsRequest) (*pb.ExecuteTxsResponse, error)

ExecuteTxs handles ExecuteTxs method call from execution API.

func (*Server) GetTxs

func (s *Server) GetTxs(ctx context.Context, req *pb.GetTxsRequest) (*pb.GetTxsResponse, error)

GetTxs handles GetTxs method call from execution API.

func (*Server) InitChain

func (s *Server) InitChain(ctx context.Context, req *pb.InitChainRequest) (*pb.InitChainResponse, error)

InitChain handles InitChain method call from execution API.

func (*Server) SetFinal

func (s *Server) SetFinal(ctx context.Context, req *pb.SetFinalRequest) (*pb.SetFinalResponse, error)

SetFinal handles SetFinal method call from execution API.

Jump to

Keyboard shortcuts

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