Documentation ¶
Index ¶
- Variables
- type BroadcastOutbound
- type Config
- type CoreService
- type GRPCServer
- func (svr *GRPCServer) EstimateActionGasConsumption(ctx context.Context, in *iotexapi.EstimateActionGasConsumptionRequest) (*iotexapi.EstimateActionGasConsumptionResponse, error)
- func (svr *GRPCServer) EstimateGasForAction(ctx context.Context, in *iotexapi.EstimateGasForActionRequest) (*iotexapi.EstimateGasForActionResponse, error)
- func (svr *GRPCServer) GetAccount(ctx context.Context, in *iotexapi.GetAccountRequest) (*iotexapi.GetAccountResponse, error)
- func (svr *GRPCServer) GetActPoolActions(ctx context.Context, in *iotexapi.GetActPoolActionsRequest) (*iotexapi.GetActPoolActionsResponse, error)
- func (svr *GRPCServer) GetActions(ctx context.Context, in *iotexapi.GetActionsRequest) (*iotexapi.GetActionsResponse, error)
- func (svr *GRPCServer) GetBlockMetas(ctx context.Context, in *iotexapi.GetBlockMetasRequest) (*iotexapi.GetBlockMetasResponse, error)
- func (svr *GRPCServer) GetChainMeta(ctx context.Context, in *iotexapi.GetChainMetaRequest) (*iotexapi.GetChainMetaResponse, error)
- func (svr *GRPCServer) GetElectionBuckets(ctx context.Context, in *iotexapi.GetElectionBucketsRequest) (*iotexapi.GetElectionBucketsResponse, error)
- func (svr *GRPCServer) GetEpochMeta(ctx context.Context, in *iotexapi.GetEpochMetaRequest) (*iotexapi.GetEpochMetaResponse, error)
- func (svr *GRPCServer) GetEvmTransfersByActionHash(ctx context.Context, in *iotexapi.GetEvmTransfersByActionHashRequest) (*iotexapi.GetEvmTransfersByActionHashResponse, error)
- func (svr *GRPCServer) GetEvmTransfersByBlockHeight(ctx context.Context, in *iotexapi.GetEvmTransfersByBlockHeightRequest) (*iotexapi.GetEvmTransfersByBlockHeightResponse, error)
- func (svr *GRPCServer) GetLogs(ctx context.Context, in *iotexapi.GetLogsRequest) (*iotexapi.GetLogsResponse, error)
- func (svr *GRPCServer) GetRawBlocks(ctx context.Context, in *iotexapi.GetRawBlocksRequest) (*iotexapi.GetRawBlocksResponse, error)
- func (svr *GRPCServer) GetReceiptByAction(ctx context.Context, in *iotexapi.GetReceiptByActionRequest) (*iotexapi.GetReceiptByActionResponse, error)
- func (svr *GRPCServer) GetServerMeta(ctx context.Context, in *iotexapi.GetServerMetaRequest) (*iotexapi.GetServerMetaResponse, error)
- func (svr *GRPCServer) GetTransactionLogByActionHash(ctx context.Context, in *iotexapi.GetTransactionLogByActionHashRequest) (*iotexapi.GetTransactionLogByActionHashResponse, error)
- func (svr *GRPCServer) GetTransactionLogByBlockHeight(ctx context.Context, in *iotexapi.GetTransactionLogByBlockHeightRequest) (*iotexapi.GetTransactionLogByBlockHeightResponse, error)
- func (svr *GRPCServer) ReadContract(ctx context.Context, in *iotexapi.ReadContractRequest) (*iotexapi.ReadContractResponse, error)
- func (svr *GRPCServer) ReadContractStorage(ctx context.Context, in *iotexapi.ReadContractStorageRequest) (*iotexapi.ReadContractStorageResponse, error)
- func (svr *GRPCServer) ReadState(ctx context.Context, in *iotexapi.ReadStateRequest) (*iotexapi.ReadStateResponse, error)
- func (svr *GRPCServer) SendAction(ctx context.Context, in *iotexapi.SendActionRequest) (*iotexapi.SendActionResponse, error)
- func (svr *GRPCServer) Start(_ context.Context) error
- func (svr *GRPCServer) Stop(_ context.Context) error
- func (svr *GRPCServer) StreamBlocks(in *iotexapi.StreamBlocksRequest, ...) error
- func (svr *GRPCServer) StreamLogs(in *iotexapi.StreamLogsRequest, stream iotexapi.APIService_StreamLogsServer) error
- func (svr *GRPCServer) SuggestGasPrice(ctx context.Context, in *iotexapi.SuggestGasPriceRequest) (*iotexapi.SuggestGasPriceResponse, error)
- func (svr *GRPCServer) TraceTransactionStructLogs(ctx context.Context, in *iotexapi.TraceTransactionStructLogsRequest) (*iotexapi.TraceTransactionStructLogsResponse, error)
- type HTTPServer
- type Listener
- type LogListener
- type Option
- type ReadCache
- type ReadKey
- type Responder
- type ServerV2
- type StreamBlocksServer
- type Web3Handler
- type WebsocketServer
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotFound indicates the record isn't found ErrNotFound = errors.New("not found") )
Functions ¶
This section is empty.
Types ¶
type BroadcastOutbound ¶
BroadcastOutbound sends a broadcast message to the whole network
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config represents the config to setup api
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) // ReceiptByAction gets receipt with corresponding action hash ReceiptByAction(actHash hash.Hash256) (*action.Receipt, 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(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) // StreamBlocks streams blocks StreamBlocks(stream iotexapi.APIService_StreamBlocksServer) error // StreamLogs streams logs that match the filter condition StreamLogs(in *iotexapi.LogsFilter, stream iotexapi.APIService_StreamLogsServer) 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) // ActionsByBlock returns all actions in a block ActionsByBlock(blkHash string, start uint64, count uint64) ([]*iotexapi.ActionInfo, error) // ActionsInBlockByHash returns all actions in a block ActionsInBlockByHash(string) ([]action.SealedEnvelope, []*action.Receipt, error) // ActPoolActions returns the all Transaction Identifiers in the mempool ActPoolActions(actHashes []string) ([]*iotextypes.Action, 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) // BlockMetas returns blockmetas response within the height range BlockMetas(start uint64, count uint64) ([]*iotextypes.BlockMeta, error) // BlockMetaByHash returns blockmeta response by block hash BlockMetaByHash(blkHash string) (*iotextypes.BlockMeta, 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) // 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 }
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 and the pointer to api coreservice
func NewGRPCServer ¶ added in v1.6.3
func NewGRPCServer(core CoreService, grpcPort int) *GRPCServer
NewGRPCServer creates a new grpc server
func (*GRPCServer) EstimateActionGasConsumption ¶ added in v1.6.3
func (svr *GRPCServer) EstimateActionGasConsumption(ctx context.Context, in *iotexapi.EstimateActionGasConsumptionRequest) (*iotexapi.EstimateActionGasConsumptionResponse, error)
EstimateActionGasConsumption estimate gas consume for action without signature
func (*GRPCServer) EstimateGasForAction ¶ added in v1.6.3
func (svr *GRPCServer) EstimateGasForAction(ctx context.Context, in *iotexapi.EstimateGasForActionRequest) (*iotexapi.EstimateGasForActionResponse, error)
EstimateGasForAction estimates gas for action
func (*GRPCServer) GetAccount ¶ added in v1.6.3
func (svr *GRPCServer) GetAccount(ctx context.Context, in *iotexapi.GetAccountRequest) (*iotexapi.GetAccountResponse, error)
GetAccount returns the metadata of an account
func (*GRPCServer) GetActPoolActions ¶ added in v1.6.3
func (svr *GRPCServer) GetActPoolActions(ctx context.Context, in *iotexapi.GetActPoolActionsRequest) (*iotexapi.GetActPoolActionsResponse, error)
GetActPoolActions returns the all Transaction Identifiers in the mempool
func (*GRPCServer) GetActions ¶ added in v1.6.3
func (svr *GRPCServer) GetActions(ctx context.Context, in *iotexapi.GetActionsRequest) (*iotexapi.GetActionsResponse, error)
GetActions returns actions
func (*GRPCServer) GetBlockMetas ¶ added in v1.6.3
func (svr *GRPCServer) GetBlockMetas(ctx context.Context, in *iotexapi.GetBlockMetasRequest) (*iotexapi.GetBlockMetasResponse, error)
GetBlockMetas returns block metadata
func (*GRPCServer) GetChainMeta ¶ added in v1.6.3
func (svr *GRPCServer) GetChainMeta(ctx context.Context, in *iotexapi.GetChainMetaRequest) (*iotexapi.GetChainMetaResponse, error)
GetChainMeta returns blockchain metadata
func (*GRPCServer) GetElectionBuckets ¶ added in v1.6.3
func (svr *GRPCServer) GetElectionBuckets(ctx context.Context, in *iotexapi.GetElectionBucketsRequest) (*iotexapi.GetElectionBucketsResponse, error)
GetElectionBuckets returns the native election buckets.
func (*GRPCServer) GetEpochMeta ¶ added in v1.6.3
func (svr *GRPCServer) GetEpochMeta(ctx context.Context, in *iotexapi.GetEpochMetaRequest) (*iotexapi.GetEpochMetaResponse, error)
GetEpochMeta gets epoch metadata
func (*GRPCServer) GetEvmTransfersByActionHash ¶ added in v1.6.3
func (svr *GRPCServer) GetEvmTransfersByActionHash(ctx context.Context, in *iotexapi.GetEvmTransfersByActionHashRequest) (*iotexapi.GetEvmTransfersByActionHashResponse, error)
GetEvmTransfersByActionHash returns evm transfers by action hash
func (*GRPCServer) GetEvmTransfersByBlockHeight ¶ added in v1.6.3
func (svr *GRPCServer) GetEvmTransfersByBlockHeight(ctx context.Context, in *iotexapi.GetEvmTransfersByBlockHeightRequest) (*iotexapi.GetEvmTransfersByBlockHeightResponse, error)
GetEvmTransfersByBlockHeight returns evm transfers by block height
func (*GRPCServer) GetLogs ¶ added in v1.6.3
func (svr *GRPCServer) GetLogs(ctx context.Context, in *iotexapi.GetLogsRequest) (*iotexapi.GetLogsResponse, error)
GetLogs get logs filtered by contract address and topics
func (*GRPCServer) GetRawBlocks ¶ added in v1.6.3
func (svr *GRPCServer) GetRawBlocks(ctx context.Context, in *iotexapi.GetRawBlocksRequest) (*iotexapi.GetRawBlocksResponse, error)
GetRawBlocks gets raw block data
func (*GRPCServer) GetReceiptByAction ¶ added in v1.6.3
func (svr *GRPCServer) GetReceiptByAction(ctx context.Context, in *iotexapi.GetReceiptByActionRequest) (*iotexapi.GetReceiptByActionResponse, error)
GetReceiptByAction gets receipt with corresponding action hash
func (*GRPCServer) GetServerMeta ¶ added in v1.6.3
func (svr *GRPCServer) GetServerMeta(ctx context.Context, in *iotexapi.GetServerMetaRequest) (*iotexapi.GetServerMetaResponse, error)
GetServerMeta gets the server metadata
func (*GRPCServer) GetTransactionLogByActionHash ¶ added in v1.6.3
func (svr *GRPCServer) GetTransactionLogByActionHash(ctx context.Context, in *iotexapi.GetTransactionLogByActionHashRequest) (*iotexapi.GetTransactionLogByActionHashResponse, error)
GetTransactionLogByActionHash returns transaction log by action hash
func (*GRPCServer) GetTransactionLogByBlockHeight ¶ added in v1.6.3
func (svr *GRPCServer) GetTransactionLogByBlockHeight(ctx context.Context, in *iotexapi.GetTransactionLogByBlockHeightRequest) (*iotexapi.GetTransactionLogByBlockHeightResponse, error)
GetTransactionLogByBlockHeight returns transaction log by block height
func (*GRPCServer) ReadContract ¶ added in v1.6.3
func (svr *GRPCServer) ReadContract(ctx context.Context, in *iotexapi.ReadContractRequest) (*iotexapi.ReadContractResponse, error)
ReadContract reads the state in a contract address specified by the slot
func (*GRPCServer) ReadContractStorage ¶ added in v1.6.3
func (svr *GRPCServer) ReadContractStorage(ctx context.Context, in *iotexapi.ReadContractStorageRequest) (*iotexapi.ReadContractStorageResponse, error)
ReadContractStorage reads contract's storage
func (*GRPCServer) ReadState ¶ added in v1.6.3
func (svr *GRPCServer) ReadState(ctx context.Context, in *iotexapi.ReadStateRequest) (*iotexapi.ReadStateResponse, error)
ReadState reads state on blockchain
func (*GRPCServer) SendAction ¶ added in v1.6.3
func (svr *GRPCServer) SendAction(ctx context.Context, in *iotexapi.SendActionRequest) (*iotexapi.SendActionResponse, error)
SendAction is the API to send an action to blockchain.
func (*GRPCServer) Start ¶ added in v1.6.3
func (svr *GRPCServer) Start(_ context.Context) error
Start starts the GRPC server
func (*GRPCServer) Stop ¶ added in v1.6.3
func (svr *GRPCServer) Stop(_ context.Context) error
Stop stops the GRPC server
func (*GRPCServer) StreamBlocks ¶ added in v1.6.3
func (svr *GRPCServer) StreamBlocks(in *iotexapi.StreamBlocksRequest, stream iotexapi.APIService_StreamBlocksServer) error
StreamBlocks streams blocks
func (*GRPCServer) StreamLogs ¶ added in v1.6.3
func (svr *GRPCServer) StreamLogs(in *iotexapi.StreamLogsRequest, stream iotexapi.APIService_StreamLogsServer) error
StreamLogs streams logs that match the filter condition
func (*GRPCServer) SuggestGasPrice ¶ added in v1.6.3
func (svr *GRPCServer) SuggestGasPrice(ctx context.Context, in *iotexapi.SuggestGasPriceRequest) (*iotexapi.SuggestGasPriceResponse, error)
SuggestGasPrice suggests gas price
func (*GRPCServer) TraceTransactionStructLogs ¶ added in v1.6.3
func (svr *GRPCServer) TraceTransactionStructLogs(ctx context.Context, in *iotexapi.TraceTransactionStructLogsRequest) (*iotexapi.TraceTransactionStructLogsResponse, error)
TraceTransactionStructLogs get trace transaction struct logs
type HTTPServer ¶ added in v1.8.0
type HTTPServer struct {
// contains filtered or unexported fields
}
HTTPServer handles requests from http protocol
func NewHTTPServer ¶ added in v1.8.0
func NewHTTPServer(route string, port int, handler Web3Handler) *HTTPServer
NewHTTPServer creates a new http server
func (*HTTPServer) ServeHTTP ¶ added in v1.8.0
func (hSvr *HTTPServer) ServeHTTP(w http.ResponseWriter, req *http.Request)
type Listener ¶ added in v0.7.1
type Listener interface { Start() error Stop() error ReceiveBlock(*block.Block) error AddResponder(Responder) error }
Listener pass new block to all responders
func NewChainListener ¶ added in v0.7.1
NewChainListener returns a new blockchain chainListener
type LogListener ¶ added in v1.8.0
type LogListener struct {
// contains filtered or unexported fields
}
LogListener defines the log listener in subscribed through API
func NewLogListener ¶ added in v1.8.0
func NewLogListener(in *logfilter.LogFilter, stream iotexapi.APIService_StreamLogsServer, errChan chan error) *LogListener
NewLogListener returns a new log listener
type Option ¶
Option is the option to override the api config
func WithActionIndex ¶ added in v1.7.1
func WithActionIndex() Option
WithActionIndex is the option which enables action index related features
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 Responder ¶ added in v0.7.1
Responder responds to new block
func NewBlockListener ¶ added in v0.7.1
func NewBlockListener(stream iotexapi.APIService_StreamBlocksServer, errChan chan error) Responder
NewBlockListener returns a new block listener
type ServerV2 ¶ added in v1.6.3
type ServerV2 struct { GrpcServer *GRPCServer // 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) 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
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 WebsocketServer ¶ added in v1.8.0
type WebsocketServer struct {
// contains filtered or unexported fields
}
WebsocketServer handles requests from websocket protocol
func NewWebSocketServer ¶ added in v1.8.0
func NewWebSocketServer(route string, port int, handler Web3Handler) *WebsocketServer
NewWebSocketServer creates a new websocket server
func (*WebsocketServer) ServeHTTP ¶ added in v1.8.0
func (wsSvr *WebsocketServer) ServeHTTP(w http.ResponseWriter, req *http.Request)