grpc

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2018 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GRPCUnMarshalBlock

func GRPCUnMarshalBlock(b *pb.Block, inclTx bool, fullTx bool) (*types.Block, error)

func GRPCUnMarshalHeader

func GRPCUnMarshalHeader(b *pb.Block) *types.Header

Types

type Client

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

func Dial

func Dial(rawurl string) (*Client, error)

Dial listens the url and returns grpc client

func DialContext

func DialContext(ctx context.Context, rawurl string) (*Client, error)

DialContext returns a Clients with given rul

func New

func New(conn *grpc.ClientConn) *Client

New returns a Client

func (*Client) BlockByHash

func (c *Client) BlockByHash(ctx context.Context, hash common.Hash) (*pb.Block, error)

func (*Client) BlockByNumber

func (c *Client) BlockByNumber(ctx context.Context, number *big.Int) (*pb.Block, error)

BlockByNumber returns a block from the current canonical chain. If number is nil, the latest known block is returned.

Note that loading full blocks requires two requests. Use HeaderByNumber if you don't need all transactions or uncle headers.

func (*Client) Close

func (c *Client) Close()

Close close the connections

func (*Client) HeaderByHash

func (c *Client) HeaderByHash(ctx context.Context, hash common.Hash) (*types.Header, error)

HeaderByHash returns the block header with the given hash.

func (*Client) HeaderByNumber

func (c *Client) HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error)

HeaderByNumber returns a block header from the current canonical chain. If number is nil, the latest known header is returned.

func (*Client) TransactionCount

func (c *Client) TransactionCount(ctx context.Context, blockHash common.Hash) (uint, error)

TransactionCount returns the total number of transactions in the given block.

type Config

type Config struct {
	Modules []string `toml:",omitempty"`
	DataDir string   `toml:",omitempt"`
	Host    string   `toml:",omitempty"`
	Port    int      `toml:",omitempty"`

	JsonRpcHost string `toml:",omitempty"`
	JsonRpcPort int    `toml:",omitempty"`

	IpcPath string `toml:",omitempty"`
}

Config grpc configuration

func (*Config) Address

func (c *Config) Address() string

Address returns the grpc server address

func (*Config) IpcAddress

func (c *Config) IpcAddress() string

IpcAddress returns the ipc server address

func (*Config) JsonHttpAddress

func (c *Config) JsonHttpAddress() string

JsonHttpAddress returns the restfull json http server address

type GApi

type GApi interface {
	IsPublic() bool
	Namespace() string
	RegisterServer(*grpc.Server)
	RegisterJsonRpc(context.Context, *runtime.ServeMux, string, []grpc.DialOption)
}

GApi Named Register is better

type Server

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

Server GRpc Server

func NewServer

func NewServer(dataDir string, modules []string, cfg *Config) *Server

NewServer creates a new implementation of a Server

func (*Server) Register

func (s *Server) Register(ctx context.Context, gapis []GApi)

Register registers all the given GApis

func (*Server) Start

func (s *Server) Start() error

Start starts the underlying grpc.Server

func (*Server) Stop

func (s *Server) Stop()

Stop stops the underlying grpc.Server and close the listener

Directories

Path Synopsis
v1
admin
Package admin is a reverse proxy.
Package admin is a reverse proxy.
cpc
Package cpc is a reverse proxy.
Package cpc is a reverse proxy.
debug
Package debug is a reverse proxy.
Package debug is a reverse proxy.
miner
Package miner is a reverse proxy.
Package miner is a reverse proxy.
net
personal
Package personal is a reverse proxy.
Package personal is a reverse proxy.
txpool
Package txpool is a reverse proxy.
Package txpool is a reverse proxy.

Jump to

Keyboard shortcuts

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