api

package
v0.0.0-...-55b7c22 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2022 License: Apache-2.0 Imports: 64 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

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 GRPCServer

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

GRPCServer contains grpc server and the pointer to api coreservice

func NewGRPCServer

func NewGRPCServer(core *coreService, grpcPort int) *GRPCServer

NewGRPCServer creates a new grpc server

func (*GRPCServer) EstimateActionGasConsumption

EstimateActionGasConsumption estimate gas consume for action without signature

func (*GRPCServer) EstimateGasForAction

EstimateGasForAction estimates gas for action

func (*GRPCServer) GetAccount

GetAccount returns the metadata of an account

func (*GRPCServer) GetActPoolActions

GetActPoolActions returns the all Transaction Identifiers in the mempool

func (*GRPCServer) GetActions

GetActions returns actions

func (*GRPCServer) GetBlockMetas

GetBlockMetas returns block metadata

func (*GRPCServer) GetChainMeta

GetChainMeta returns blockchain metadata

func (*GRPCServer) GetElectionBuckets

GetElectionBuckets returns the native election buckets.

func (*GRPCServer) GetEpochMeta

GetEpochMeta gets epoch metadata

func (*GRPCServer) GetEvmTransfersByActionHash

GetEvmTransfersByActionHash returns evm transfers by action hash

func (*GRPCServer) GetEvmTransfersByBlockHeight

GetEvmTransfersByBlockHeight returns evm transfers by block height

func (*GRPCServer) GetLogs

GetLogs get logs filtered by contract address and topics

func (*GRPCServer) GetRawBlocks

GetRawBlocks gets raw block data

func (*GRPCServer) GetReceiptByAction

GetReceiptByAction gets receipt with corresponding action hash

func (*GRPCServer) GetServerMeta

GetServerMeta gets the server metadata

func (*GRPCServer) GetTransactionLogByActionHash

GetTransactionLogByActionHash returns transaction log by action hash

func (*GRPCServer) GetTransactionLogByBlockHeight

GetTransactionLogByBlockHeight returns transaction log by block height

func (*GRPCServer) ReadContract

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

func (*GRPCServer) ReadContractStorage

ReadContractStorage reads contract's storage

func (*GRPCServer) ReadState

ReadState reads state on blockchain

func (*GRPCServer) SendAction

SendAction is the API to send an action to blockchain.

func (*GRPCServer) Start

func (svr *GRPCServer) Start() error

Start starts the GRPC server

func (*GRPCServer) Stop

func (svr *GRPCServer) Stop() error

Stop stops the GRPC server

func (*GRPCServer) StreamBlocks

StreamBlocks streams blocks

func (*GRPCServer) StreamLogs

StreamLogs streams logs that match the filter condition

func (*GRPCServer) SuggestGasPrice

SuggestGasPrice suggests gas price

func (*GRPCServer) TraceTransactionStructLogs

TraceTransactionStructLogs get trace transaction struct logs

type Listener

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

Listener pass new block to all responders

func NewChainListener

func NewChainListener(c int) 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

func WithNativeElection(committee committee.Committee) Option

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

type ReadCache

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

ReadCache stores read results

func NewReadCache

func NewReadCache() *ReadCache

NewReadCache returns a new read cache

func (*ReadCache) Clear

func (rc *ReadCache) Clear()

Clear clears the cache

func (*ReadCache) Exit

func (rc *ReadCache) Exit()

Exit implements the Responder interface

func (*ReadCache) Get

func (rc *ReadCache) Get(key hash.Hash160) ([]byte, bool)

Get reads according to key

func (*ReadCache) Put

func (rc *ReadCache) Put(key hash.Hash160, value []byte)

Put writes according to key

func (*ReadCache) ReceiveBlock

func (rc *ReadCache) ReceiveBlock(*block.Block) error

ReceiveBlock receives the new block

type ReadKey

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

func (*ReadKey) Hash

func (k *ReadKey) Hash() hash.Hash160

Hash returns the hash of key's json string

type Responder

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

Responder responds to new block

func NewBlockListener

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

NewBlockListener returns a new block listener

type ServerV2

type ServerV2 struct {
	GrpcServer *GRPCServer
	// contains filtered or unexported fields
}

ServerV2 provides api for user to interact with blockchain data

func NewServerV2

func NewServerV2(
	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,
) (*ServerV2, error)

NewServerV2 creates a new server with coreService and GRPC Server

func (*ServerV2) Start

func (svr *ServerV2) Start() error

Start starts the CoreService and the GRPC server

func (*ServerV2) Stop

func (svr *ServerV2) Stop() error

Stop stops the GRPC server and the CoreService

type ServiceClient

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)
	// read contract storage
	ReadContractStorage(ctx context.Context, in *iotexapi.ReadContractStorageRequest, opts ...grpc.CallOption) (*iotexapi.ReadContractStorageResponse, error)
	// TraceTransactionStructLogs get trace transaction struct logs
	TraceTransactionStructLogs(ctx context.Context, in *iotexapi.TraceTransactionStructLogsRequest, opts ...grpc.CallOption) (*iotexapi.TraceTransactionStructLogsResponse, 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

type StreamBlocksServer interface {
	Send(*iotexapi.StreamBlocksResponse) error
	grpc.ServerStream
}

StreamBlocksServer defines the interface of a rpc stream server

type Web3Server

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

Web3Server contains web3 server and the pointer to api coreservice

func NewWeb3Server

func NewWeb3Server(core *coreService, httpPort int, cacheURL string) *Web3Server

NewWeb3Server creates a new web3 server

func (*Web3Server) ServeHTTP

func (svr *Web3Server) ServeHTTP(w http.ResponseWriter, req *http.Request)

func (*Web3Server) Start

func (svr *Web3Server) Start() error

Start starts the API server

func (*Web3Server) Stop

func (svr *Web3Server) Stop() error

Stop stops the API server

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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