iotex-core: Index | Files

package api

import ""


Package Files

api.go apitestclient.go blocklistener.go listener.go logfilter.go


var (
    // ErrInternalServer indicates the internal server error
    ErrInternalServer = errors.New("internal server error")
    // ErrReceipt indicates the error of receipt
    ErrReceipt = errors.New("invalid receipt")
    // ErrAction indicates the error of action
    ErrAction = errors.New("invalid action")

type BroadcastOutbound Uses

type BroadcastOutbound func(ctx context.Context, chainID uint32, msg proto.Message) error

BroadcastOutbound sends a broadcast message to the whole network

type Config Uses

type Config struct {
    // contains filtered or unexported fields

Config represents the config to setup api

type Listener Uses

type Listener interface {
    Start() error
    Stop() error
    ReceiveBlock(*block.Block) error
    AddResponder(Responder) error

Listener pass new block to all responders

func NewChainListener Uses

func NewChainListener() Listener

NewChainListener returns a new blockchain chainListener

type LogFilter Uses

type LogFilter struct {
    // contains filtered or unexported fields

LogFilter contains options for contract log filtering.

func (*LogFilter) Exit Uses

func (l *LogFilter) Exit()

Exit send to error channel

func (*LogFilter) MatchLogs Uses

func (l *LogFilter) MatchLogs(receipts []*action.Receipt) []*iotextypes.Log

MatchLogs returns matching logs in a given block

func (*LogFilter) Respond Uses

func (l *LogFilter) Respond(blk *block.Block) error

Respond to new block

type Option Uses

type Option func(cfg *Config) error

Option is the option to override the api config

func WithBroadcastOutbound Uses

func WithBroadcastOutbound(broadcastHandler BroadcastOutbound) Option

WithBroadcastOutbound is the option to broadcast msg outbound

func WithNativeElection Uses

func WithNativeElection(committee committee.Committee) Option

WithNativeElection is the option to return native election data through API.

type Responder Uses

type Responder interface {
    Respond(*block.Block) error

Responder responds to new block

func NewBlockListener Uses

func NewBlockListener(stream iotexapi.APIService_StreamBlocksServer, errChan chan error) Responder

NewBlockListener returns a new block listener

func NewLogFilter Uses

func NewLogFilter(in *iotexapi.LogsFilter, stream iotexapi.APIService_StreamLogsServer, errChan chan error) Responder

NewLogFilter returns a new log filter

type Server Uses

type Server struct {
    // contains filtered or unexported fields

Server provides api for user to query blockchain data

func NewServer Uses

func NewServer(
    cfg config.Config,
    chain blockchain.Blockchain,
    sf factory.Factory,
    dao blockdao.BlockDAO,
    indexer blockindex.Indexer,
    systemLogIndexer *systemlog.Indexer,
    actPool actpool.ActPool,
    registry *protocol.Registry,
    opts ...Option,
) (*Server, error)

NewServer creates a new server

func (*Server) EstimateActionGasConsumption Uses

func (api *Server) EstimateActionGasConsumption(ctx context.Context, in *iotexapi.EstimateActionGasConsumptionRequest) (respone *iotexapi.EstimateActionGasConsumptionResponse, err error)

EstimateActionGasConsumption estimate gas consume for action without signature

func (*Server) EstimateGasForAction Uses

func (api *Server) EstimateGasForAction(ctx context.Context, in *iotexapi.EstimateGasForActionRequest) (*iotexapi.EstimateGasForActionResponse, error)

EstimateGasForAction estimates gas for action

func (*Server) GetAccount Uses

func (api *Server) GetAccount(ctx context.Context, in *iotexapi.GetAccountRequest) (*iotexapi.GetAccountResponse, error)

GetAccount returns the metadata of an account

func (*Server) GetActionByActionHash Uses

func (api *Server) GetActionByActionHash(h hash.Hash256) (action.SealedEnvelope, error)

GetActionByActionHash returns action by action hash

func (*Server) GetActions Uses

func (api *Server) GetActions(ctx context.Context, in *iotexapi.GetActionsRequest) (*iotexapi.GetActionsResponse, error)

GetActions returns actions

func (*Server) GetBlockMetas Uses

func (api *Server) GetBlockMetas(ctx context.Context, in *iotexapi.GetBlockMetasRequest) (*iotexapi.GetBlockMetasResponse, error)

GetBlockMetas returns block metadata

func (*Server) GetChainMeta Uses

func (api *Server) GetChainMeta(ctx context.Context, in *iotexapi.GetChainMetaRequest) (*iotexapi.GetChainMetaResponse, error)

GetChainMeta returns blockchain metadata

func (*Server) GetElectionBuckets Uses

func (api *Server) GetElectionBuckets(
    ctx context.Context,
    in *iotexapi.GetElectionBucketsRequest,
) (*iotexapi.GetElectionBucketsResponse, error)

GetElectionBuckets returns the native election buckets.

func (*Server) GetEpochMeta Uses

func (api *Server) GetEpochMeta(
    ctx context.Context,
    in *iotexapi.GetEpochMetaRequest,
) (*iotexapi.GetEpochMetaResponse, error)

GetEpochMeta gets epoch metadata

func (*Server) GetEvmTransfersByActionHash Uses

func (api *Server) GetEvmTransfersByActionHash(ctx context.Context, in *iotexapi.GetEvmTransfersByActionHashRequest) (*iotexapi.GetEvmTransfersByActionHashResponse, error)

GetEvmTransfersByActionHash returns evm transfers by action hash

func (*Server) GetEvmTransfersByBlockHeight Uses

func (api *Server) GetEvmTransfersByBlockHeight(ctx context.Context, in *iotexapi.GetEvmTransfersByBlockHeightRequest) (*iotexapi.GetEvmTransfersByBlockHeightResponse, error)

GetEvmTransfersByBlockHeight returns evm transfers by block height

func (*Server) GetLogs Uses

func (api *Server) GetLogs(
    ctx context.Context,
    in *iotexapi.GetLogsRequest,
) (*iotexapi.GetLogsResponse, error)

GetLogs get logs filtered by contract address and topics

func (*Server) GetRawBlocks Uses

func (api *Server) GetRawBlocks(
    ctx context.Context,
    in *iotexapi.GetRawBlocksRequest,
) (*iotexapi.GetRawBlocksResponse, error)

GetRawBlocks gets raw block data

func (*Server) GetReceiptByAction Uses

func (api *Server) GetReceiptByAction(ctx context.Context, in *iotexapi.GetReceiptByActionRequest) (*iotexapi.GetReceiptByActionResponse, error)

GetReceiptByAction gets receipt with corresponding action hash

func (*Server) GetReceiptByActionHash Uses

func (api *Server) GetReceiptByActionHash(h hash.Hash256) (*action.Receipt, error)

GetReceiptByActionHash returns receipt by action hash

func (*Server) GetServerMeta Uses

func (api *Server) GetServerMeta(ctx context.Context,
    in *iotexapi.GetServerMetaRequest) (*iotexapi.GetServerMetaResponse, error)

GetServerMeta gets the server metadata

func (*Server) ReadContract Uses

func (api *Server) ReadContract(ctx context.Context, in *iotexapi.ReadContractRequest) (*iotexapi.ReadContractResponse, error)

ReadContract reads the state in a contract address specified by the slot

func (*Server) ReadState Uses

func (api *Server) ReadState(ctx context.Context, in *iotexapi.ReadStateRequest) (*iotexapi.ReadStateResponse, error)

ReadState reads state on blockchain

func (*Server) SendAction Uses

func (api *Server) SendAction(ctx context.Context, in *iotexapi.SendActionRequest) (*iotexapi.SendActionResponse, error)

SendAction is the API to send an action to blockchain.

func (*Server) Start Uses

func (api *Server) Start() error

Start starts the API server

func (*Server) Stop Uses

func (api *Server) Stop() error

Stop stops the API server

func (*Server) StreamBlocks Uses

func (api *Server) StreamBlocks(in *iotexapi.StreamBlocksRequest, stream iotexapi.APIService_StreamBlocksServer) error

StreamBlocks streams blocks

func (*Server) StreamLogs Uses

func (api *Server) StreamLogs(in *iotexapi.StreamLogsRequest, stream iotexapi.APIService_StreamLogsServer) error

StreamLogs streams logs that match the filter condition

func (*Server) SuggestGasPrice Uses

func (api *Server) SuggestGasPrice(ctx context.Context, in *iotexapi.SuggestGasPriceRequest) (*iotexapi.SuggestGasPriceResponse, error)

SuggestGasPrice suggests gas price

type ServiceClient Uses

type ServiceClient interface {
    // get the address detail of an address
    GetAccount(ctx context.Context, in *iotexapi.GetAccountRequest, opts ...grpc.CallOption) (*iotexapi.GetAccountResponse, error)
    // get action(s) by:
    // 1. start index and action count
    // 2. action hash
    // 3. address with start index and action count
    // 4. get unconfirmed actions by address with start index and action count
    // 5. block hash with start index and action count
    GetActions(ctx context.Context, in *iotexapi.GetActionsRequest, opts ...grpc.CallOption) (*iotexapi.GetActionsResponse, error)
    // get block metadata(s) by:
    // 1. start index and block count
    // 2. block hash
    GetBlockMetas(ctx context.Context, in *iotexapi.GetBlockMetasRequest, opts ...grpc.CallOption) (*iotexapi.GetBlockMetasResponse, error)
    // get chain metadata
    GetChainMeta(ctx context.Context, in *iotexapi.GetChainMetaRequest, opts ...grpc.CallOption) (*iotexapi.GetChainMetaResponse, error)
    // get server version
    GetServerMeta(ctx context.Context, in *iotexapi.GetServerMetaRequest, opts ...grpc.CallOption) (*iotexapi.GetServerMetaResponse, error)
    // sendAction
    SendAction(ctx context.Context, in *iotexapi.SendActionRequest, opts ...grpc.CallOption) (*iotexapi.SendActionResponse, error)
    // get receipt by action Hash
    GetReceiptByAction(ctx context.Context, in *iotexapi.GetReceiptByActionRequest, opts ...grpc.CallOption) (*iotexapi.GetReceiptByActionResponse, error)
    // TODO: read contract
    ReadContract(ctx context.Context, in *iotexapi.ReadContractRequest, opts ...grpc.CallOption) (*iotexapi.ReadContractResponse, error)
    // suggest gas price
    SuggestGasPrice(ctx context.Context, in *iotexapi.SuggestGasPriceRequest, opts ...grpc.CallOption) (*iotexapi.SuggestGasPriceResponse, error)
    // estimate gas for action
    EstimateGasForAction(ctx context.Context, in *iotexapi.EstimateGasForActionRequest, opts ...grpc.CallOption) (*iotexapi.EstimateGasForActionResponse, error)
    // estimate gas for action and transfer not sealed
    EstimateActionGasConsumption(ctx context.Context, in *iotexapi.EstimateActionGasConsumptionRequest, opts ...grpc.CallOption) (*iotexapi.EstimateActionGasConsumptionResponse, error)
    // read state from blockchain
    ReadState(ctx context.Context, in *iotexapi.ReadStateRequest, opts ...grpc.CallOption) (*iotexapi.ReadStateResponse, error)
    // get epoch metadata
    GetEpochMeta(ctx context.Context, in *iotexapi.GetEpochMetaRequest, opts ...grpc.CallOption) (*iotexapi.GetEpochMetaResponse, error)
    // get raw blocks data
    GetRawBlocks(ctx context.Context, in *iotexapi.GetRawBlocksRequest, opts ...grpc.CallOption) (*iotexapi.GetRawBlocksResponse, error)
    // get logs filtered by contract address and topics
    GetLogs(ctx context.Context, in *iotexapi.GetLogsRequest, opts ...grpc.CallOption) (*iotexapi.GetLogsResponse, error)
    // get evm transfers by action hash
    GetEvmTransfersByActionHash(ctx context.Context, in *iotexapi.GetEvmTransfersByActionHashRequest, opts ...grpc.CallOption) (*iotexapi.GetEvmTransfersByActionHashResponse, error)
    // get evm transfers by block height
    GetEvmTransfersByBlockHeight(ctx context.Context, in *iotexapi.GetEvmTransfersByBlockHeightRequest, opts ...grpc.CallOption) (*iotexapi.GetEvmTransfersByBlockHeightResponse, error)
    // get block info in stream
    StreamBlocks(ctx context.Context, in *iotexapi.StreamBlocksRequest, opts ...grpc.CallOption) (iotexapi.APIService_StreamBlocksClient, error)
    // get filtered logs in stream
    StreamLogs(ctx context.Context, in *iotexapi.StreamLogsRequest, opts ...grpc.CallOption) (iotexapi.APIService_StreamLogsClient, error)
    // get native election buckets
    GetElectionBuckets(ctx context.Context, in *iotexapi.GetElectionBucketsRequest, opts ...grpc.CallOption) (*iotexapi.GetElectionBucketsResponse, error)

ServiceClient is the api service client interface corresponding to the one in This interface is used by mockgen for test purposes. Remember to update it whenever definitions in api.proto change.

Package api imports 43 packages (graph) and is imported by 1 packages. Updated 2020-05-28. Refresh now. Tools for package owners.