Documentation ¶
Index ¶
- Constants
- Variables
- func MakeTxRawMsgsForSign(tx *types.Transaction, utxos ...*rpcpb.Utxo) ([][]byte, error)
- func ParseAddrFrom(sc *script.Script, txHash *crypto.HashType, idx uint32, tr ChainTxReader) (string, error)
- func RegisterGatewayHandler(name string, h GatewayHandler)
- func RegisterService(name string, s Service)
- func RegisterServiceWithGatewayHandler(name string, s Service, h GatewayHandler)
- type ChainBlockReader
- type ChainTxReader
- type Config
- type GRPCServer
- type GatewayHandler
- type HTTPConfig
- type Server
- type Service
- type TxPoolReader
Constants ¶
const ( DefaultGrpcLimits = 128 DefaultHTTPLimits = 128 )
Define const
Variables ¶
var (
ErrAPINotSupported = errors.New("api not supported")
)
Functions ¶
func MakeTxRawMsgsForSign ¶ added in v0.3.0
MakeTxRawMsgsForSign make tx raw msg for sign
func ParseAddrFrom ¶ added in v0.3.1
func ParseAddrFrom( sc *script.Script, txHash *crypto.HashType, idx uint32, tr ChainTxReader, ) (string, error)
ParseAddrFrom parse addr from scriptPubkey
func RegisterGatewayHandler ¶
func RegisterGatewayHandler(name string, h GatewayHandler)
RegisterGatewayHandler registers a new http gateway handler for gRPC service
func RegisterService ¶
RegisterService registers a new gRPC service
func RegisterServiceWithGatewayHandler ¶
func RegisterServiceWithGatewayHandler(name string, s Service, h GatewayHandler)
RegisterServiceWithGatewayHandler registers a gRPC service with gateway handler
Types ¶
type ChainBlockReader ¶ added in v0.3.0
type ChainBlockReader interface { ChainTxReader // LoadBlockInfoByTxHash(crypto.HashType) (*types.Block, *types.Transaction, error) ReadBlockFromDB(*crypto.HashType) (*types.Block, int, error) EternalBlock() *types.Block TailBlock() *types.Block GetLogs(from, to uint32, topicslist [][][]byte) ([]*types.Log, error) FilterLogs(logs []*types.Log, topicslist [][][]byte) ([]*types.Log, error) TailState() *state.StateDB GetEvmByHeight(msg types.Message, height uint32) (*vm.EVM, func() error, error) }
ChainBlockReader defines chain block reader interface
type ChainTxReader ¶ added in v0.3.0
type ChainTxReader interface { LoadBlockInfoByTxHash(crypto.HashType) (*types.Block, *types.Transaction, error) GetDataFromDB([]byte) ([]byte, error) GetTxReceipt(*crypto.HashType) (*types.Receipt, error) }
ChainTxReader defines chain tx reader interface
type Config ¶
type Config struct { Enabled bool `mapstructure:"enabled"` Address string `mapstructure:"address"` Port int `mapstructure:"port"` HTTP HTTPConfig `mapstructure:"http"` GrpcLimits int `mapstructure:"grpc_limits"` HTTPLimits int `mapstructure:"http_limits"` HTTPCors []string `mapstructure:"http_cors"` FaucetKeyFile string `mapstructure:"faucet_keyfile"` SubScribeBlocks bool `mapstructure:"subscribe_blocks"` SubScribeLogs bool `mapstructure:"subscribe_logs"` }
Config defines the configurations of rpc server
type GRPCServer ¶
type GRPCServer interface { GetChainReader() service.ChainReader GetTxHandler() service.TxHandler GetWalletAgent() service.WalletAgent GetEventBus() eventbus.Bus Proc() goprocess.Process Stop() }
GRPCServer interface breaks cycle import dependency
type GatewayHandler ¶
GatewayHandler defines the register func of http gateway handler for gRPC service
type HTTPConfig ¶
HTTPConfig defines the address/port of rest api over http
type Server ¶
type Server struct { ChainReader service.ChainReader TxHandler service.TxHandler WalletAgent service.WalletAgent // contains filtered or unexported fields }
Server defines the rpc server
func NewServer ¶
func NewServer(parent goprocess.Process, cfg *Config, cr service.ChainReader, txh service.TxHandler, wa service.WalletAgent, bus eventbus.Bus) *Server
NewServer creates a RPC server instance.
func (*Server) GetChainReader ¶
func (s *Server) GetChainReader() service.ChainReader
GetChainReader returns an interface to observe chain state
func (*Server) GetEventBus ¶
GetEventBus returns a interface to publish events
func (*Server) GetTxHandler ¶
GetTxHandler returns a handler to deal with transactions
func (*Server) GetWalletAgent ¶ added in v0.3.0
func (s *Server) GetWalletAgent() service.WalletAgent
GetWalletAgent returns the wallet related service handler