Documentation ¶
Index ¶
- Variables
- func NewChainListener(c int) apitypes.Listener
- func NewGRPCBlockListener(handler streamHandler, errChan chan error) apitypes.Responder
- func NewGRPCLogListener(in *logfilter.LogFilter, handler streamHandler, errChan chan error) apitypes.Responder
- func NewWeb3BlockListener(handler streamHandler) apitypes.Responder
- func NewWeb3LogListener(filter *logfilter.LogFilter, handler streamHandler) apitypes.Responder
- func RecoveryInterceptor() grpc_recovery.Option
- type BroadcastOutbound
- type CoreService
- type GRPCServer
- type HTTPServer
- type Option
- type ReadCache
- type ReadKey
- type ServerV2
- type StreamBlocksServer
- type Web3Handler
- type WebsocketHandler
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotFound indicates the record isn't found ErrNotFound = errors.New("not found") )
Functions ¶
func NewChainListener ¶ added in v0.7.1
NewChainListener returns a new blockchain chainListener
func NewGRPCBlockListener ¶ added in v1.8.1
NewGRPCBlockListener returns a new gRPC block listener
func NewGRPCLogListener ¶ added in v1.8.1
func NewGRPCLogListener(in *logfilter.LogFilter, handler streamHandler, errChan chan error) apitypes.Responder
NewGRPCLogListener returns a new log listener
func NewWeb3BlockListener ¶ added in v1.8.1
NewWeb3BlockListener returns a new websocket block listener
func NewWeb3LogListener ¶ added in v1.8.1
NewWeb3LogListener returns a new websocket block listener
func RecoveryInterceptor ¶ added in v1.8.1
func RecoveryInterceptor() grpc_recovery.Option
RecoveryInterceptor handles panic to a custom error
Types ¶
type BroadcastOutbound ¶
BroadcastOutbound sends a broadcast message to the whole network
type CoreService ¶ added in v1.7.1
type CoreService interface { // Account returns the metadata of an account Account(addr address.Address) (*iotextypes.AccountMeta, *iotextypes.BlockIdentifier, error) // ChainMeta returns blockchain metadata ChainMeta() (*iotextypes.ChainMeta, string, error) // ServerMeta gets the server metadata ServerMeta() (packageVersion string, packageCommitID string, gitStatus string, goVersion string, buildTime string) // SendAction is the API to send an action to blockchain. SendAction(ctx context.Context, in *iotextypes.Action) (string, error) // ReadContract reads the state in a contract address specified by the slot ReadContract(ctx context.Context, callerAddr address.Address, sc *action.Execution) (string, *iotextypes.Receipt, error) // ReadState reads state on blockchain ReadState(protocolID string, height string, methodName []byte, arguments [][]byte) (*iotexapi.ReadStateResponse, error) // SuggestGasPrice suggests gas price SuggestGasPrice() (uint64, error) // EstimateGasForAction estimates gas for action EstimateGasForAction(ctx context.Context, in *iotextypes.Action) (uint64, error) // EpochMeta gets epoch metadata EpochMeta(epochNum uint64) (*iotextypes.EpochData, uint64, []*iotexapi.BlockProducerInfo, error) // RawBlocks gets raw block data RawBlocks(startHeight uint64, count uint64, withReceipts bool, withTransactionLogs bool) ([]*iotexapi.BlockInfo, error) // ElectionBuckets returns the native election buckets. ElectionBuckets(epochNum uint64) ([]*iotextypes.ElectionBucket, error) // ReceiptByActionHash returns receipt by action hash ReceiptByActionHash(h hash.Hash256) (*action.Receipt, error) // TransactionLogByActionHash returns transaction log by action hash TransactionLogByActionHash(actHash string) (*iotextypes.TransactionLog, error) // TransactionLogByBlockHeight returns transaction log by block height TransactionLogByBlockHeight(blockHeight uint64) (*iotextypes.BlockIdentifier, *iotextypes.TransactionLogs, error) // Start starts the API server Start(ctx context.Context) error // Stop stops the API server Stop(ctx context.Context) error // Actions returns actions within the range Actions(start uint64, count uint64) ([]*iotexapi.ActionInfo, error) // Action returns action by action hash Action(actionHash string, checkPending bool) (*iotexapi.ActionInfo, error) // ActionsByAddress returns all actions associated with an address ActionsByAddress(addr address.Address, start uint64, count uint64) ([]*iotexapi.ActionInfo, error) // ActionByActionHash returns action by action hash ActionByActionHash(h hash.Hash256) (action.SealedEnvelope, hash.Hash256, uint64, uint32, error) // ActPoolActions returns the all Transaction Identifiers in the actpool ActionsInActPool(actHashes []string) ([]action.SealedEnvelope, error) // BlockByHeightRange returns blocks within the height range BlockByHeightRange(uint64, uint64) ([]*apitypes.BlockWithReceipts, error) // BlockByHeight returns the block and its receipt from block height BlockByHeight(uint64) (*apitypes.BlockWithReceipts, error) // BlockByHash returns the block and its receipt BlockByHash(string) (*apitypes.BlockWithReceipts, error) // UnconfirmedActionsByAddress returns all unconfirmed actions in actpool associated with an address UnconfirmedActionsByAddress(address string, start uint64, count uint64) ([]*iotexapi.ActionInfo, error) // EstimateGasForNonExecution estimates action gas except execution EstimateGasForNonExecution(action.Action) (uint64, error) // EstimateExecutionGasConsumption estimate gas consumption for execution action EstimateExecutionGasConsumption(ctx context.Context, sc *action.Execution, callerAddr address.Address) (uint64, error) // LogsInBlockByHash filter logs in the block by hash LogsInBlockByHash(filter *logfilter.LogFilter, blockHash hash.Hash256) ([]*action.Log, error) // LogsInRange filter logs among [start, end] blocks LogsInRange(filter *logfilter.LogFilter, start, end, paginationSize uint64) ([]*action.Log, []hash.Hash256, error) // EVMNetworkID returns the network id of evm EVMNetworkID() uint32 // ChainID returns the chain id of evm ChainID() uint32 // ReadContractStorage reads contract's storage ReadContractStorage(ctx context.Context, addr address.Address, key []byte) ([]byte, error) // ChainListener returns the instance of Listener ChainListener() apitypes.Listener // SimulateExecution simulates execution SimulateExecution(context.Context, address.Address, *action.Execution) ([]byte, *action.Receipt, error) // SyncingProgress returns the syncing status of node SyncingProgress() (uint64, uint64, uint64) // TipHeight returns the tip of the chain TipHeight() uint64 // PendingNonce returns the pending nonce of an account PendingNonce(address.Address) (uint64, error) // ReceiveBlock broadcasts the block to api subscribers ReceiveBlock(blk *block.Block) error // BlockHashByBlockHeight returns block hash by block height BlockHashByBlockHeight(blkHeight uint64) (hash.Hash256, error) }
CoreService provides api interface for user to interact with blockchain data
type GRPCServer ¶ added in v1.6.3
type GRPCServer struct {
// contains filtered or unexported fields
}
GRPCServer contains grpc server
func NewGRPCServer ¶ added in v1.6.3
func NewGRPCServer(core CoreService, grpcPort int) *GRPCServer
NewGRPCServer creates a new grpc server
type HTTPServer ¶ added in v1.8.0
type HTTPServer struct {
// contains filtered or unexported fields
}
HTTPServer crates a http server
func NewHTTPServer ¶ added in v1.8.0
func NewHTTPServer(route string, port int, handler http.Handler) *HTTPServer
NewHTTPServer creates a new http server
type Option ¶
type Option func(cfg *coreService)
Option is the option to override the api config
func WithBroadcastOutbound ¶
func WithBroadcastOutbound(broadcastHandler BroadcastOutbound) Option
WithBroadcastOutbound is the option to broadcast msg outbound
func WithNativeElection ¶ added in v0.9.0
WithNativeElection is the option to return native election data through API.
type ReadCache ¶ added in v1.5.0
type ReadCache struct {
// contains filtered or unexported fields
}
ReadCache stores read results
func NewReadCache ¶ added in v1.5.0
func NewReadCache() *ReadCache
NewReadCache returns a new read cache
type ReadKey ¶ added in v1.5.0
type ReadKey struct { Name string `json:"name,omitempty"` Height string `json:"height,omitempty"` Method []byte `json:"method,omitempty"` Args [][]byte `json:"args,omitempty"` }
ReadKey represents a read key
type ServerV2 ¶ added in v1.6.3
type ServerV2 struct {
// contains filtered or unexported fields
}
ServerV2 provides api for user to interact with blockchain data
func NewServerV2 ¶ added in v1.6.3
func NewServerV2( cfg config.API, chain blockchain.Blockchain, bs blocksync.BlockSync, sf factory.Factory, dao blockdao.BlockDAO, indexer blockindex.Indexer, bfIndexer blockindex.BloomFilterIndexer, actPool actpool.ActPool, registry *protocol.Registry, opts ...Option, ) (*ServerV2, error)
NewServerV2 creates a new server with coreService and GRPC Server
func (*ServerV2) CoreService ¶ added in v1.8.1
func (svr *ServerV2) CoreService() CoreService
CoreService returns the coreservice of the api
func (*ServerV2) ReceiveBlock ¶ added in v1.8.0
ReceiveBlock receives the new block
type StreamBlocksServer ¶ added in v1.1.0
type StreamBlocksServer interface { Send(*iotexapi.StreamBlocksResponse) error grpc.ServerStream }
StreamBlocksServer defines the interface of a rpc stream server
type Web3Handler ¶ added in v1.8.0
type Web3Handler interface {
HandlePOSTReq(context.Context, io.Reader, apitypes.Web3ResponseWriter) error
}
Web3Handler handle JRPC request
func NewWeb3Handler ¶ added in v1.8.0
func NewWeb3Handler(core CoreService, cacheURL string) Web3Handler
NewWeb3Handler creates a handle to process web3 requests
type WebsocketHandler ¶ added in v1.8.2
type WebsocketHandler struct {
// contains filtered or unexported fields
}
WebsocketHandler handles requests from websocket protocol
func NewWebsocketHandler ¶ added in v1.8.2
func NewWebsocketHandler(web3Handler Web3Handler) *WebsocketHandler
NewWebsocketHandler creates a new websocket handler
func (*WebsocketHandler) ServeHTTP ¶ added in v1.8.2
func (wsSvr *WebsocketHandler) ServeHTTP(w http.ResponseWriter, req *http.Request)