rpc

package
v2.1.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2019 License: LGPL-3.0 Imports: 30 Imported by: 3

Documentation

Index

Constants

View Source
const (
	API   = "api"
	Admin = "admin"
)

const

View Source
const (
	// DefaultHTTPLimit default max http conns
	DefaultHTTPLimit = 128
	// MaxGateWayRecvMsgSize Deafult max message size  gateway's grpc client can receive
	MaxGateWayRecvMsgSize = 64 * 1024 * 1024
)
View Source
const (
	DefaultConnectionLimits = 128
	MaxRecvMsgSize          = 64 * 1024 * 1024
)

Const

Variables

View Source
var (
	ErrEmptyRPCListenList = errors.New("empty rpc listen list")
)

Errors

Functions

func Dial

func Dial(target string) (*grpc.ClientConn, error)

Dial returns a client connection.

func Run added in v0.3.0

func Run(config *nebletpb.RPCConfig) error

Run start gateway proxy to mapping grpc to http.

Types

type APIService

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

APIService implements the RPC API service interface.

func (*APIService) Call added in v0.3.0

func (s *APIService) Call(ctx context.Context, req *rpcpb.TransactionRequest) (*rpcpb.CallResponse, error)

Call is the RPC API handler.

func (*APIService) EstimateGas added in v1.0.0

func (s *APIService) EstimateGas(ctx context.Context, req *rpcpb.TransactionRequest) (*rpcpb.GasResponse, error)

EstimateGas Compute the smart contract gas consumption.

func (*APIService) GetAccountState

func (s *APIService) GetAccountState(ctx context.Context, req *rpcpb.GetAccountStateRequest) (*rpcpb.GetAccountStateResponse, error)

GetAccountState is the RPC API handler.

func (*APIService) GetBlockByHash added in v0.3.0

func (s *APIService) GetBlockByHash(ctx context.Context, req *rpcpb.GetBlockByHashRequest) (*rpcpb.BlockResponse, error)

GetBlockByHash get block info by the block hash

func (*APIService) GetBlockByHeight added in v1.0.0

func (s *APIService) GetBlockByHeight(ctx context.Context, req *rpcpb.GetBlockByHeightRequest) (*rpcpb.BlockResponse, error)

GetBlockByHeight get block info by the block hash

func (*APIService) GetDynasty added in v1.0.0

func (s *APIService) GetDynasty(ctx context.Context, req *rpcpb.ByBlockHeightRequest) (*rpcpb.GetDynastyResponse, error)

GetDynasty is the RPC API handler.

func (*APIService) GetEventsByHash added in v1.0.0

func (s *APIService) GetEventsByHash(ctx context.Context, req *rpcpb.HashRequest) (*rpcpb.EventsResponse, error)

GetEventsByHash return events by tx hash.

func (*APIService) GetGasPrice added in v1.0.0

func (s *APIService) GetGasPrice(ctx context.Context, req *rpcpb.NonParamsRequest) (*rpcpb.GasPriceResponse, error)

GetGasPrice get gas price from chain.

func (*APIService) GetNebState added in v0.3.0

func (s *APIService) GetNebState(ctx context.Context, req *rpcpb.NonParamsRequest) (*rpcpb.GetNebStateResponse, error)

GetNebState is the RPC API handler.

func (*APIService) GetTransactionByContract added in v1.0.2

func (s *APIService) GetTransactionByContract(ctx context.Context, req *rpcpb.GetTransactionByContractRequest) (*rpcpb.TransactionResponse, error)

GetTransactionByContract get transaction info by the contract address

func (*APIService) GetTransactionReceipt added in v1.0.0

func (s *APIService) GetTransactionReceipt(ctx context.Context, req *rpcpb.GetTransactionByHashRequest) (*rpcpb.TransactionResponse, error)

GetTransactionReceipt get transaction info by the transaction hash

func (*APIService) LatestIrreversibleBlock added in v1.0.0

func (s *APIService) LatestIrreversibleBlock(ctx context.Context, req *rpcpb.NonParamsRequest) (*rpcpb.BlockResponse, error)

LatestIrreversibleBlock is the RPC API handler.

func (*APIService) SendRawTransaction added in v0.3.0

func (s *APIService) SendRawTransaction(ctx context.Context, req *rpcpb.SendRawTransactionRequest) (*rpcpb.SendTransactionResponse, error)

SendRawTransaction submit the signed transaction raw data to txpool

func (*APIService) Subscribe added in v1.0.0

func (s *APIService) Subscribe(req *rpcpb.SubscribeRequest, gs rpcpb.ApiService_SubscribeServer) error

Subscribe ..

func (*APIService) VerifySignature

func (s *APIService) VerifySignature(ctx context.Context, req *rpcpb.VerifySignatureRequest) (*rpcpb.VerifySignatureResponse, error)

verify signature.

type AdminService added in v1.0.0

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

AdminService implements the RPC admin service interface.

func (*AdminService) Accounts added in v1.0.0

func (s *AdminService) Accounts(ctx context.Context, req *rpcpb.NonParamsRequest) (*rpcpb.AccountsResponse, error)

Accounts is the RPC API handler.

func (*AdminService) GenerateRandomSeed added in v1.0.2

func (s *AdminService) GenerateRandomSeed(ctx context.Context, req *rpcpb.GenerateRandomSeedRequest) (*rpcpb.GenerateRandomSeedResponse, error)

GenerateRandomSeed generate block's rand info

func (*AdminService) GetConfig added in v1.0.0

func (s *AdminService) GetConfig(ctx context.Context, req *rpcpb.NonParamsRequest) (*rpcpb.GetConfigResponse, error)

GetConfig is the RPC API handler.

func (*AdminService) LockAccount added in v1.0.0

func (s *AdminService) LockAccount(ctx context.Context, req *rpcpb.LockAccountRequest) (*rpcpb.LockAccountResponse, error)

LockAccount lock address

func (*AdminService) NewAccount added in v1.0.0

func (s *AdminService) NewAccount(ctx context.Context, req *rpcpb.NewAccountRequest) (*rpcpb.NewAccountResponse, error)

NewAccount generate a new address with passphrase

func (*AdminService) NodeInfo added in v1.0.0

func (s *AdminService) NodeInfo(ctx context.Context, req *rpcpb.NonParamsRequest) (*rpcpb.NodeInfoResponse, error)

NodeInfo is the RPC API handler

限制来自同一个ip的节点连接请求的数量 (例如来自同一个ip的节点连接不能超过10,如果当前连接的列表中来自同一个ip的节点数量为10,则拒绝所有后面来自该ip的节点的连接请求) 主动发起连接时判断目标节点的ip是否在已连接的列表中,如果已经存在,则不建立该连接 路由同步增加相应的策略 一个桶的地址不能包含两个以上节点相同的 /24 ip地址块 整个路由表不能包含十个以上节点相同的 /24 ip地址块 更改路由同步的算法,路由同步时候不再同步离目标节点最近的那些节点

func (*AdminService) SendTransaction added in v1.0.0

func (s *AdminService) SendTransaction(ctx context.Context, req *rpcpb.TransactionRequest) (*rpcpb.SendTransactionResponse, error)

SendTransaction is the RPC API handler.

func (*AdminService) SendTransactionWithPassphrase added in v1.0.0

func (s *AdminService) SendTransactionWithPassphrase(ctx context.Context, req *rpcpb.SendTransactionPassphraseRequest) (*rpcpb.SendTransactionResponse, error)

SendTransactionWithPassphrase send transaction with the from addr passphrase

func (*AdminService) SignHash added in v1.0.0

func (s *AdminService) SignHash(ctx context.Context, req *rpcpb.SignHashRequest) (*rpcpb.SignHashResponse, error)

SignHash is the RPC API handler.

func (*AdminService) SignTransactionWithPassphrase added in v1.0.0

func (s *AdminService) SignTransactionWithPassphrase(ctx context.Context, req *rpcpb.SignTransactionPassphraseRequest) (*rpcpb.SignTransactionPassphraseResponse, error)

SignTransactionWithPassphrase sign transaction with the from addr passphrase

func (*AdminService) StartPprof added in v1.0.0

func (s *AdminService) StartPprof(ctx context.Context, req *rpcpb.PprofRequest) (*rpcpb.PprofResponse, error)

StartPprof start pprof

func (*AdminService) UnlockAccount added in v1.0.0

func (s *AdminService) UnlockAccount(ctx context.Context, req *rpcpb.UnlockAccountRequest) (*rpcpb.UnlockAccountResponse, error)

UnlockAccount unlock address with the passphrase

type GRPCServer added in v1.0.0

type GRPCServer interface {
	// Start start server
	Start() error

	// Stop stop server
	Stop()

	// Neblet return neblet
	Neblet() core.Neblet

	RunGateway() error
}

GRPCServer server interface for api & management etc.

type Neblet

type Neblet interface {
	Config() *nebletpb.Config
	StartPprof(string) error
	BlockChain() *core.BlockChain
	AccountManager() core.AccountManager
	NetService() nebnet.Service
	EventEmitter() *core.EventEmitter
	Consensus() core.Consensus
}

Neblet interface breaks cycle import dependency and hides unused services.

type Server

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

Server is the RPC server type.

func NewServer

func NewServer(neblet core.Neblet) *Server

NewServer creates a new RPC server and registers the rpc endpoints.

func (*Server) Neblet

func (s *Server) Neblet() core.Neblet

Neblet returns weak reference to Neblet.

func (*Server) RunGateway added in v0.3.0

func (s *Server) RunGateway() error

RunGateway run grpc mapping to http after apiserver have started.

func (*Server) Start

func (s *Server) Start() error

Start starts the rpc server and serves incoming requests.

func (*Server) Stop

func (s *Server) Stop()

Stop stops the rpc server and closes listener.

Directories

Path Synopsis
Package mock_pb is a generated GoMock package.
Package mock_pb is a generated GoMock package.
Package rpcpb is a generated protocol buffer package.
Package rpcpb is a generated protocol buffer package.
testing

Jump to

Keyboard shortcuts

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