api

package
v1.4.0-rc0 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2021 License: Apache-2.0 Imports: 47 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
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")
)

Functions

This section is empty.

Types

type BroadcastOutbound

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

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 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

func NewChainListener() Listener

NewChainListener returns a new blockchain chainListener

type Option

type Option func(cfg *Config) error

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

func WithNativeElection(committee committee.Committee) Option

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

type Responder added in v0.7.1

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

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 Server

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

Server provides api for user to query blockchain data

func NewServer

func NewServer(
	cfg config.Config,
	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,
) (*Server, error)

NewServer creates a new server

func (*Server) EstimateActionGasConsumption added in v0.7.2

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

EstimateGasForAction estimates gas for action

func (*Server) GetAccount

GetAccount returns the metadata of an account

func (*Server) GetActPoolActions added in v1.1.3

GetActPoolActions returns the all Transaction Identifiers in the mempool

func (*Server) GetActionByActionHash added in v0.11.0

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

GetActionByActionHash returns action by action hash

func (*Server) GetActions

GetActions returns actions

func (*Server) GetBlockMetas

GetBlockMetas returns block metadata

func (*Server) GetChainMeta

GetChainMeta returns blockchain metadata

func (*Server) GetElectionBuckets added in v0.9.0

GetElectionBuckets returns the native election buckets.

func (*Server) GetEpochMeta

GetEpochMeta gets epoch metadata

func (*Server) GetEvmTransfersByActionHash added in v1.0.0

GetEvmTransfersByActionHash returns evm transfers by action hash

func (*Server) GetEvmTransfersByBlockHeight added in v1.0.0

GetEvmTransfersByBlockHeight returns evm transfers by block height

func (*Server) GetLogs added in v0.7.1

GetLogs get logs filtered by contract address and topics

func (*Server) GetRawBlocks added in v0.6.0

GetRawBlocks gets raw block data

func (*Server) GetReceiptByAction

GetReceiptByAction gets receipt with corresponding action hash

func (*Server) GetReceiptByActionHash added in v0.11.0

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

GetReceiptByActionHash returns receipt by action hash

func (*Server) GetServerMeta

GetServerMeta gets the server metadata

func (*Server) GetTransactionLogByActionHash added in v1.1.0

GetTransactionLogByActionHash returns transaction log by action hash

func (*Server) GetTransactionLogByBlockHeight added in v1.1.0

GetTransactionLogByBlockHeight returns transaction log by block height

func (*Server) ReadContract

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

func (*Server) ReadState

ReadState reads state on blockchain

func (*Server) SendAction

SendAction is the API to send an action to blockchain.

func (*Server) Start

func (api *Server) Start() error

Start starts the API server

func (*Server) Stop

func (api *Server) Stop() error

Stop stops the API server

func (*Server) StreamBlocks added in v0.6.0

StreamBlocks streams blocks

func (*Server) StreamLogs added in v0.7.1

StreamLogs streams logs that match the filter condition

func (*Server) SuggestGasPrice

SuggestGasPrice suggests gas price

type ServiceClient added in v0.6.0

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)
	// deprecated
	GetEvmTransfersByActionHash(ctx context.Context, in *iotexapi.GetEvmTransfersByActionHashRequest, opts ...grpc.CallOption) (*iotexapi.GetEvmTransfersByActionHashResponse, error)
	// deprecated
	GetEvmTransfersByBlockHeight(ctx context.Context, in *iotexapi.GetEvmTransfersByBlockHeightRequest, opts ...grpc.CallOption) (*iotexapi.GetEvmTransfersByBlockHeightResponse, error)
	// get transaction log by action hash
	GetTransactionLogByActionHash(ctx context.Context, in *iotexapi.GetTransactionLogByActionHashRequest, opts ...grpc.CallOption) (*iotexapi.GetTransactionLogByActionHashResponse, error)
	// get transaction log by block height
	GetTransactionLogByBlockHeight(ctx context.Context, in *iotexapi.GetTransactionLogByBlockHeightRequest, opts ...grpc.CallOption) (*iotexapi.GetTransactionLogByBlockHeightResponse, 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)
	// get actions from act pool
	GetActPoolActions(ctx context.Context, in *iotexapi.GetActPoolActionsRequest, opts ...grpc.CallOption) (*iotexapi.GetActPoolActionsResponse, error)
}

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

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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