api

package
v2.2.0-rc0 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2025 License: Apache-2.0 Imports: 96 Imported by: 0

Documentation

Overview

Package api is a generated GoMock package.

Package api is a generated GoMock package.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound            = errors.New("not found")
	ErrArchiveNotSupported = errors.New("archive-mode not supported")
)
View Source
var DefaultConfig = Config{
	UseRDS:             false,
	GRPCPort:           14014,
	HTTPPort:           15014,
	WebSocketPort:      16014,
	TpsWindow:          10,
	GasStation:         gasstation.DefaultConfig,
	RangeQueryLimit:    1000,
	BatchRequestLimit:  _defaultBatchRequestLimit,
	WebsocketRateLimit: 5,
	ListenerLimit:      5000,
	ReadyDuration:      time.Second * 30,
}

DefaultConfig is the default config

Functions

func NewChainListener

func NewChainListener(c int) apitypes.Listener

NewChainListener returns a new blockchain chainListener

func NewGRPCBlockListener

func NewGRPCBlockListener(handler streamHandler, errChan chan error) apitypes.Responder

NewGRPCBlockListener returns a new gRPC block listener

func NewGRPCLogListener

func NewGRPCLogListener(in *logfilter.LogFilter, handler streamHandler, errChan chan error) apitypes.Responder

NewGRPCLogListener returns a new log listener

func NewWeb3BlockListener

func NewWeb3BlockListener(handler streamHandler) apitypes.Responder

NewWeb3BlockListener returns a new websocket block listener

func NewWeb3LogListener

func NewWeb3LogListener(filter *logfilter.LogFilter, handler streamHandler) apitypes.Responder

NewWeb3LogListener returns a new websocket block listener

func RecoveryInterceptor

func RecoveryInterceptor() grpc_recovery.Option

RecoveryInterceptor handles panic to a custom error

func WithStreamContext

func WithStreamContext(ctx context.Context) context.Context

Types

type ActionRadio

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

ActionRadio broadcasts actions to the network

func NewActionRadio

func NewActionRadio(broadcastHandler BroadcastOutbound, chainID uint32, opts ...ActionRadioOption) *ActionRadio

NewActionRadio creates a new ActionRadio

func (*ActionRadio) OnAdded

func (ar *ActionRadio) OnAdded(selp *action.SealedEnvelope)

OnAdded broadcasts the action to the network

func (*ActionRadio) OnRemoved

func (ar *ActionRadio) OnRemoved(act *action.SealedEnvelope)

OnRemoved does nothing

func (*ActionRadio) Start

func (ar *ActionRadio) Start() error

Start starts the action radio

func (*ActionRadio) Stop

func (ar *ActionRadio) Stop() error

Stop stops the action radio

type ActionRadioOption

type ActionRadioOption func(*ActionRadio)

ActionRadioOption is the option to create ActionRadio

func WithMessageBatch

func WithMessageBatch() ActionRadioOption

WithMessageBatch enables message batching

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 {
	UseRDS          bool              `yaml:"useRDS"`
	GRPCPort        int               `yaml:"port"`
	HTTPPort        int               `yaml:"web3port"`
	WebSocketPort   int               `yaml:"webSocketPort"`
	RedisCacheURL   string            `yaml:"redisCacheURL"`
	TpsWindow       int               `yaml:"tpsWindow"`
	GasStation      gasstation.Config `yaml:"gasStation"`
	RangeQueryLimit uint64            `yaml:"rangeQueryLimit"`
	Tracer          tracer.Config     `yaml:"tracer"`
	// BatchRequestLimit is the maximum number of requests in a batch.
	BatchRequestLimit int `yaml:"batchRequestLimit"`
	// WebsocketRateLimit is the maximum number of messages per second per client.
	WebsocketRateLimit int `yaml:"websocketRateLimit"`
	// ListenerLimit is the maximum number of listeners.
	ListenerLimit int `yaml:"listenerLimit"`
	// ReadyDuration is the duration to wait for the server to be ready.
	ReadyDuration time.Duration `yaml:"readyDuration"`
}

Config is the api service config

type CoreService

type CoreService interface {
	WithHeight(uint64) CoreServiceReaderWithHeight
	// 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.Envelope) (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)
	// SuggestGasTipCap suggests gas tip cap
	SuggestGasTipCap() (*big.Int, error)
	// FeeHistory returns the fee history
	FeeHistory(ctx context.Context, blocks, lastBlock uint64, rewardPercentiles []float64) (uint64, [][]*big.Int, []*big.Int, []float64, []*big.Int, []float64, 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)
	// TODO: unify the three get action by hash methods: Action, ActionByActionHash, PendingActionByActionHash
	// 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, *block.Block, uint32, error)
	// PendingActionByActionHash returns action by action hash
	PendingActionByActionHash(h hash.Hash256) (*action.SealedEnvelope, error)
	// ActionsInActPool 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)
	// EstimateMigrateStakeGasConsumption estimates gas for migrate stake
	EstimateMigrateStakeGasConsumption(context.Context, *action.MigrateStake, address.Address) (uint64, []byte, 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.Envelope, callerAddr address.Address, opts ...protocol.SimulateOption) (uint64, []byte, 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)
	// Genesis returns the genesis of the chain
	Genesis() genesis.Genesis
	// 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.Envelope) ([]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)
	// TraceTransaction returns the trace result of a transaction
	TraceTransaction(ctx context.Context, actHash string, config *tracers.TraceConfig) ([]byte, *action.Receipt, any, error)
	// TraceCall returns the trace result of a call
	TraceCall(ctx context.Context,
		callerAddr address.Address,
		blkNumOrHash any,
		contractAddress string,
		nonce uint64,
		amount *big.Int,
		gasLimit uint64,
		data []byte,
		config *tracers.TraceConfig) ([]byte, *action.Receipt, any, error)

	// Track tracks the api call
	Track(ctx context.Context, start time.Time, method string, size int64, success bool)
	// BlobSidecarsByHeight returns blob sidecars by height
	BlobSidecarsByHeight(height uint64) ([]*apitypes.BlobSidecarResult, error)
}

CoreService provides api interface for user to interact with blockchain data

type CoreServiceReaderWithHeight

type CoreServiceReaderWithHeight interface {
	Account(address.Address) (*iotextypes.AccountMeta, *iotextypes.BlockIdentifier, error)
	ReadContract(context.Context, address.Address, action.Envelope) (string, *iotextypes.Receipt, error)
}

CoreServiceReaderWithHeight is an interface for state reader at certain height

type GRPCServer

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

GRPCServer contains grpc server

func NewGRPCServer

func NewGRPCServer(core CoreService, bds *blockDAOService, grpcPort int) *GRPCServer

NewGRPCServer creates a new grpc server

func (*GRPCServer) Start

func (grpc *GRPCServer) Start(_ context.Context) error

Start starts the GRPC server

func (*GRPCServer) Stop

func (grpc *GRPCServer) Stop(_ context.Context) error

Stop stops the GRPC server

type HTTPServer

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

HTTPServer crates a http server

func NewHTTPServer

func NewHTTPServer(route string, port int, handler http.Handler) *HTTPServer

NewHTTPServer creates a new http server

func (*HTTPServer) Start

func (hSvr *HTTPServer) Start(_ context.Context) error

Start starts the http server

func (*HTTPServer) Stop

func (hSvr *HTTPServer) Stop(ctx context.Context) error

Stop stops the http server

type MockCoreService

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

MockCoreService is a mock of CoreService interface.

func NewMockCoreService

func NewMockCoreService(ctrl *gomock.Controller) *MockCoreService

NewMockCoreService creates a new mock instance.

func (*MockCoreService) Account

Account mocks base method.

func (*MockCoreService) Action

func (m *MockCoreService) Action(actionHash string, checkPending bool) (*iotexapi.ActionInfo, error)

Action mocks base method.

func (*MockCoreService) ActionByActionHash

func (m *MockCoreService) ActionByActionHash(h hash.Hash256) (*action.SealedEnvelope, *block.Block, uint32, error)

ActionByActionHash mocks base method.

func (*MockCoreService) Actions

func (m *MockCoreService) Actions(start, count uint64) ([]*iotexapi.ActionInfo, error)

Actions mocks base method.

func (*MockCoreService) ActionsByAddress

func (m *MockCoreService) ActionsByAddress(addr address.Address, start, count uint64) ([]*iotexapi.ActionInfo, error)

ActionsByAddress mocks base method.

func (*MockCoreService) ActionsInActPool

func (m *MockCoreService) ActionsInActPool(actHashes []string) ([]*action.SealedEnvelope, error)

ActionsInActPool mocks base method.

func (*MockCoreService) BlobSidecarsByHeight

func (m *MockCoreService) BlobSidecarsByHeight(height uint64) ([]*types.BlobSidecarResult, error)

BlobSidecarsByHeight mocks base method.

func (*MockCoreService) BlockByHash

func (m *MockCoreService) BlockByHash(arg0 string) (*types.BlockWithReceipts, error)

BlockByHash mocks base method.

func (*MockCoreService) BlockByHeight

func (m *MockCoreService) BlockByHeight(arg0 uint64) (*types.BlockWithReceipts, error)

BlockByHeight mocks base method.

func (*MockCoreService) BlockByHeightRange

func (m *MockCoreService) BlockByHeightRange(arg0, arg1 uint64) ([]*types.BlockWithReceipts, error)

BlockByHeightRange mocks base method.

func (*MockCoreService) BlockHashByBlockHeight

func (m *MockCoreService) BlockHashByBlockHeight(blkHeight uint64) (hash.Hash256, error)

BlockHashByBlockHeight mocks base method.

func (*MockCoreService) ChainID

func (m *MockCoreService) ChainID() uint32

ChainID mocks base method.

func (*MockCoreService) ChainListener

func (m *MockCoreService) ChainListener() types.Listener

ChainListener mocks base method.

func (*MockCoreService) ChainMeta

func (m *MockCoreService) ChainMeta() (*iotextypes.ChainMeta, string, error)

ChainMeta mocks base method.

func (*MockCoreService) EVMNetworkID

func (m *MockCoreService) EVMNetworkID() uint32

EVMNetworkID mocks base method.

func (*MockCoreService) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockCoreService) ElectionBuckets

func (m *MockCoreService) ElectionBuckets(epochNum uint64) ([]*iotextypes.ElectionBucket, error)

ElectionBuckets mocks base method.

func (*MockCoreService) EpochMeta

EpochMeta mocks base method.

func (*MockCoreService) EstimateExecutionGasConsumption

func (m *MockCoreService) EstimateExecutionGasConsumption(ctx context.Context, sc action.Envelope, callerAddr address.Address, opts ...protocol.SimulateOption) (uint64, []byte, error)

EstimateExecutionGasConsumption mocks base method.

func (*MockCoreService) EstimateGasForAction

func (m *MockCoreService) EstimateGasForAction(ctx context.Context, in *iotextypes.Action) (uint64, error)

EstimateGasForAction mocks base method.

func (*MockCoreService) EstimateGasForNonExecution

func (m *MockCoreService) EstimateGasForNonExecution(arg0 action.Action) (uint64, error)

EstimateGasForNonExecution mocks base method.

func (*MockCoreService) EstimateMigrateStakeGasConsumption

func (m *MockCoreService) EstimateMigrateStakeGasConsumption(arg0 context.Context, arg1 *action.MigrateStake, arg2 address.Address) (uint64, []byte, error)

EstimateMigrateStakeGasConsumption mocks base method.

func (*MockCoreService) FeeHistory

func (m *MockCoreService) FeeHistory(ctx context.Context, blocks, lastBlock uint64, rewardPercentiles []float64) (uint64, [][]*big.Int, []*big.Int, []float64, []*big.Int, []float64, error)

FeeHistory mocks base method.

func (*MockCoreService) Genesis

func (m *MockCoreService) Genesis() genesis.Genesis

Genesis mocks base method.

func (*MockCoreService) LogsInBlockByHash

func (m *MockCoreService) LogsInBlockByHash(filter *logfilter.LogFilter, blockHash hash.Hash256) ([]*action.Log, error)

LogsInBlockByHash mocks base method.

func (*MockCoreService) LogsInRange

func (m *MockCoreService) LogsInRange(filter *logfilter.LogFilter, start, end, paginationSize uint64) ([]*action.Log, []hash.Hash256, error)

LogsInRange mocks base method.

func (*MockCoreService) PendingActionByActionHash

func (m *MockCoreService) PendingActionByActionHash(h hash.Hash256) (*action.SealedEnvelope, error)

PendingActionByActionHash mocks base method.

func (*MockCoreService) PendingNonce

func (m *MockCoreService) PendingNonce(arg0 address.Address) (uint64, error)

PendingNonce mocks base method.

func (*MockCoreService) RawBlocks

func (m *MockCoreService) RawBlocks(startHeight, count uint64, withReceipts, withTransactionLogs bool) ([]*iotexapi.BlockInfo, error)

RawBlocks mocks base method.

func (*MockCoreService) ReadContract

func (m *MockCoreService) ReadContract(ctx context.Context, callerAddr address.Address, sc action.Envelope) (string, *iotextypes.Receipt, error)

ReadContract mocks base method.

func (*MockCoreService) ReadContractStorage

func (m *MockCoreService) ReadContractStorage(ctx context.Context, addr address.Address, key []byte) ([]byte, error)

ReadContractStorage mocks base method.

func (*MockCoreService) ReadState

func (m *MockCoreService) ReadState(protocolID, height string, methodName []byte, arguments [][]byte) (*iotexapi.ReadStateResponse, error)

ReadState mocks base method.

func (*MockCoreService) ReceiptByActionHash

func (m *MockCoreService) ReceiptByActionHash(h hash.Hash256) (*action.Receipt, error)

ReceiptByActionHash mocks base method.

func (*MockCoreService) ReceiveBlock

func (m *MockCoreService) ReceiveBlock(blk *block.Block) error

ReceiveBlock mocks base method.

func (*MockCoreService) SendAction

func (m *MockCoreService) SendAction(ctx context.Context, in *iotextypes.Action) (string, error)

SendAction mocks base method.

func (*MockCoreService) ServerMeta

func (m *MockCoreService) ServerMeta() (string, string, string, string, string)

ServerMeta mocks base method.

func (*MockCoreService) SimulateExecution

func (m *MockCoreService) SimulateExecution(arg0 context.Context, arg1 address.Address, arg2 action.Envelope) ([]byte, *action.Receipt, error)

SimulateExecution mocks base method.

func (*MockCoreService) Start

func (m *MockCoreService) Start(ctx context.Context) error

Start mocks base method.

func (*MockCoreService) Stop

func (m *MockCoreService) Stop(ctx context.Context) error

Stop mocks base method.

func (*MockCoreService) SuggestGasPrice

func (m *MockCoreService) SuggestGasPrice() (uint64, error)

SuggestGasPrice mocks base method.

func (*MockCoreService) SuggestGasTipCap

func (m *MockCoreService) SuggestGasTipCap() (*big.Int, error)

SuggestGasTipCap mocks base method.

func (*MockCoreService) SyncingProgress

func (m *MockCoreService) SyncingProgress() (uint64, uint64, uint64)

SyncingProgress mocks base method.

func (*MockCoreService) TipHeight

func (m *MockCoreService) TipHeight() uint64

TipHeight mocks base method.

func (*MockCoreService) TraceCall

func (m *MockCoreService) TraceCall(ctx context.Context, callerAddr address.Address, blkNumOrHash any, contractAddress string, nonce uint64, amount *big.Int, gasLimit uint64, data []byte, config *tracers.TraceConfig) ([]byte, *action.Receipt, any, error)

TraceCall mocks base method.

func (*MockCoreService) TraceTransaction

func (m *MockCoreService) TraceTransaction(ctx context.Context, actHash string, config *tracers.TraceConfig) ([]byte, *action.Receipt, any, error)

TraceTransaction mocks base method.

func (*MockCoreService) Track

func (m *MockCoreService) Track(ctx context.Context, start time.Time, method string, size int64, success bool)

Track mocks base method.

func (*MockCoreService) TransactionLogByActionHash

func (m *MockCoreService) TransactionLogByActionHash(actHash string) (*iotextypes.TransactionLog, error)

TransactionLogByActionHash mocks base method.

func (*MockCoreService) TransactionLogByBlockHeight

func (m *MockCoreService) TransactionLogByBlockHeight(blockHeight uint64) (*iotextypes.BlockIdentifier, *iotextypes.TransactionLogs, error)

TransactionLogByBlockHeight mocks base method.

func (*MockCoreService) UnconfirmedActionsByAddress

func (m *MockCoreService) UnconfirmedActionsByAddress(address string, start, count uint64) ([]*iotexapi.ActionInfo, error)

UnconfirmedActionsByAddress mocks base method.

func (*MockCoreService) WithHeight

WithHeight mocks base method.

type MockCoreServiceMockRecorder

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

MockCoreServiceMockRecorder is the mock recorder for MockCoreService.

func (*MockCoreServiceMockRecorder) Account

func (mr *MockCoreServiceMockRecorder) Account(addr interface{}) *gomock.Call

Account indicates an expected call of Account.

func (*MockCoreServiceMockRecorder) Action

func (mr *MockCoreServiceMockRecorder) Action(actionHash, checkPending interface{}) *gomock.Call

Action indicates an expected call of Action.

func (*MockCoreServiceMockRecorder) ActionByActionHash

func (mr *MockCoreServiceMockRecorder) ActionByActionHash(h interface{}) *gomock.Call

ActionByActionHash indicates an expected call of ActionByActionHash.

func (*MockCoreServiceMockRecorder) Actions

func (mr *MockCoreServiceMockRecorder) Actions(start, count interface{}) *gomock.Call

Actions indicates an expected call of Actions.

func (*MockCoreServiceMockRecorder) ActionsByAddress

func (mr *MockCoreServiceMockRecorder) ActionsByAddress(addr, start, count interface{}) *gomock.Call

ActionsByAddress indicates an expected call of ActionsByAddress.

func (*MockCoreServiceMockRecorder) ActionsInActPool

func (mr *MockCoreServiceMockRecorder) ActionsInActPool(actHashes interface{}) *gomock.Call

ActionsInActPool indicates an expected call of ActionsInActPool.

func (*MockCoreServiceMockRecorder) BlobSidecarsByHeight

func (mr *MockCoreServiceMockRecorder) BlobSidecarsByHeight(height interface{}) *gomock.Call

BlobSidecarsByHeight indicates an expected call of BlobSidecarsByHeight.

func (*MockCoreServiceMockRecorder) BlockByHash

func (mr *MockCoreServiceMockRecorder) BlockByHash(arg0 interface{}) *gomock.Call

BlockByHash indicates an expected call of BlockByHash.

func (*MockCoreServiceMockRecorder) BlockByHeight

func (mr *MockCoreServiceMockRecorder) BlockByHeight(arg0 interface{}) *gomock.Call

BlockByHeight indicates an expected call of BlockByHeight.

func (*MockCoreServiceMockRecorder) BlockByHeightRange

func (mr *MockCoreServiceMockRecorder) BlockByHeightRange(arg0, arg1 interface{}) *gomock.Call

BlockByHeightRange indicates an expected call of BlockByHeightRange.

func (*MockCoreServiceMockRecorder) BlockHashByBlockHeight

func (mr *MockCoreServiceMockRecorder) BlockHashByBlockHeight(blkHeight interface{}) *gomock.Call

BlockHashByBlockHeight indicates an expected call of BlockHashByBlockHeight.

func (*MockCoreServiceMockRecorder) ChainID

func (mr *MockCoreServiceMockRecorder) ChainID() *gomock.Call

ChainID indicates an expected call of ChainID.

func (*MockCoreServiceMockRecorder) ChainListener

func (mr *MockCoreServiceMockRecorder) ChainListener() *gomock.Call

ChainListener indicates an expected call of ChainListener.

func (*MockCoreServiceMockRecorder) ChainMeta

func (mr *MockCoreServiceMockRecorder) ChainMeta() *gomock.Call

ChainMeta indicates an expected call of ChainMeta.

func (*MockCoreServiceMockRecorder) EVMNetworkID

func (mr *MockCoreServiceMockRecorder) EVMNetworkID() *gomock.Call

EVMNetworkID indicates an expected call of EVMNetworkID.

func (*MockCoreServiceMockRecorder) ElectionBuckets

func (mr *MockCoreServiceMockRecorder) ElectionBuckets(epochNum interface{}) *gomock.Call

ElectionBuckets indicates an expected call of ElectionBuckets.

func (*MockCoreServiceMockRecorder) EpochMeta

func (mr *MockCoreServiceMockRecorder) EpochMeta(epochNum interface{}) *gomock.Call

EpochMeta indicates an expected call of EpochMeta.

func (*MockCoreServiceMockRecorder) EstimateExecutionGasConsumption

func (mr *MockCoreServiceMockRecorder) EstimateExecutionGasConsumption(ctx, sc, callerAddr interface{}, opts ...interface{}) *gomock.Call

EstimateExecutionGasConsumption indicates an expected call of EstimateExecutionGasConsumption.

func (*MockCoreServiceMockRecorder) EstimateGasForAction

func (mr *MockCoreServiceMockRecorder) EstimateGasForAction(ctx, in interface{}) *gomock.Call

EstimateGasForAction indicates an expected call of EstimateGasForAction.

func (*MockCoreServiceMockRecorder) EstimateGasForNonExecution

func (mr *MockCoreServiceMockRecorder) EstimateGasForNonExecution(arg0 interface{}) *gomock.Call

EstimateGasForNonExecution indicates an expected call of EstimateGasForNonExecution.

func (*MockCoreServiceMockRecorder) EstimateMigrateStakeGasConsumption

func (mr *MockCoreServiceMockRecorder) EstimateMigrateStakeGasConsumption(arg0, arg1, arg2 interface{}) *gomock.Call

EstimateMigrateStakeGasConsumption indicates an expected call of EstimateMigrateStakeGasConsumption.

func (*MockCoreServiceMockRecorder) FeeHistory

func (mr *MockCoreServiceMockRecorder) FeeHistory(ctx, blocks, lastBlock, rewardPercentiles interface{}) *gomock.Call

FeeHistory indicates an expected call of FeeHistory.

func (*MockCoreServiceMockRecorder) Genesis

func (mr *MockCoreServiceMockRecorder) Genesis() *gomock.Call

Genesis indicates an expected call of Genesis.

func (*MockCoreServiceMockRecorder) LogsInBlockByHash

func (mr *MockCoreServiceMockRecorder) LogsInBlockByHash(filter, blockHash interface{}) *gomock.Call

LogsInBlockByHash indicates an expected call of LogsInBlockByHash.

func (*MockCoreServiceMockRecorder) LogsInRange

func (mr *MockCoreServiceMockRecorder) LogsInRange(filter, start, end, paginationSize interface{}) *gomock.Call

LogsInRange indicates an expected call of LogsInRange.

func (*MockCoreServiceMockRecorder) PendingActionByActionHash

func (mr *MockCoreServiceMockRecorder) PendingActionByActionHash(h interface{}) *gomock.Call

PendingActionByActionHash indicates an expected call of PendingActionByActionHash.

func (*MockCoreServiceMockRecorder) PendingNonce

func (mr *MockCoreServiceMockRecorder) PendingNonce(arg0 interface{}) *gomock.Call

PendingNonce indicates an expected call of PendingNonce.

func (*MockCoreServiceMockRecorder) RawBlocks

func (mr *MockCoreServiceMockRecorder) RawBlocks(startHeight, count, withReceipts, withTransactionLogs interface{}) *gomock.Call

RawBlocks indicates an expected call of RawBlocks.

func (*MockCoreServiceMockRecorder) ReadContract

func (mr *MockCoreServiceMockRecorder) ReadContract(ctx, callerAddr, sc interface{}) *gomock.Call

ReadContract indicates an expected call of ReadContract.

func (*MockCoreServiceMockRecorder) ReadContractStorage

func (mr *MockCoreServiceMockRecorder) ReadContractStorage(ctx, addr, key interface{}) *gomock.Call

ReadContractStorage indicates an expected call of ReadContractStorage.

func (*MockCoreServiceMockRecorder) ReadState

func (mr *MockCoreServiceMockRecorder) ReadState(protocolID, height, methodName, arguments interface{}) *gomock.Call

ReadState indicates an expected call of ReadState.

func (*MockCoreServiceMockRecorder) ReceiptByActionHash

func (mr *MockCoreServiceMockRecorder) ReceiptByActionHash(h interface{}) *gomock.Call

ReceiptByActionHash indicates an expected call of ReceiptByActionHash.

func (*MockCoreServiceMockRecorder) ReceiveBlock

func (mr *MockCoreServiceMockRecorder) ReceiveBlock(blk interface{}) *gomock.Call

ReceiveBlock indicates an expected call of ReceiveBlock.

func (*MockCoreServiceMockRecorder) SendAction

func (mr *MockCoreServiceMockRecorder) SendAction(ctx, in interface{}) *gomock.Call

SendAction indicates an expected call of SendAction.

func (*MockCoreServiceMockRecorder) ServerMeta

func (mr *MockCoreServiceMockRecorder) ServerMeta() *gomock.Call

ServerMeta indicates an expected call of ServerMeta.

func (*MockCoreServiceMockRecorder) SimulateExecution

func (mr *MockCoreServiceMockRecorder) SimulateExecution(arg0, arg1, arg2 interface{}) *gomock.Call

SimulateExecution indicates an expected call of SimulateExecution.

func (*MockCoreServiceMockRecorder) Start

func (mr *MockCoreServiceMockRecorder) Start(ctx interface{}) *gomock.Call

Start indicates an expected call of Start.

func (*MockCoreServiceMockRecorder) Stop

func (mr *MockCoreServiceMockRecorder) Stop(ctx interface{}) *gomock.Call

Stop indicates an expected call of Stop.

func (*MockCoreServiceMockRecorder) SuggestGasPrice

func (mr *MockCoreServiceMockRecorder) SuggestGasPrice() *gomock.Call

SuggestGasPrice indicates an expected call of SuggestGasPrice.

func (*MockCoreServiceMockRecorder) SuggestGasTipCap

func (mr *MockCoreServiceMockRecorder) SuggestGasTipCap() *gomock.Call

SuggestGasTipCap indicates an expected call of SuggestGasTipCap.

func (*MockCoreServiceMockRecorder) SyncingProgress

func (mr *MockCoreServiceMockRecorder) SyncingProgress() *gomock.Call

SyncingProgress indicates an expected call of SyncingProgress.

func (*MockCoreServiceMockRecorder) TipHeight

func (mr *MockCoreServiceMockRecorder) TipHeight() *gomock.Call

TipHeight indicates an expected call of TipHeight.

func (*MockCoreServiceMockRecorder) TraceCall

func (mr *MockCoreServiceMockRecorder) TraceCall(ctx, callerAddr, blkNumOrHash, contractAddress, nonce, amount, gasLimit, data, config interface{}) *gomock.Call

TraceCall indicates an expected call of TraceCall.

func (*MockCoreServiceMockRecorder) TraceTransaction

func (mr *MockCoreServiceMockRecorder) TraceTransaction(ctx, actHash, config interface{}) *gomock.Call

TraceTransaction indicates an expected call of TraceTransaction.

func (*MockCoreServiceMockRecorder) Track

func (mr *MockCoreServiceMockRecorder) Track(ctx, start, method, size, success interface{}) *gomock.Call

Track indicates an expected call of Track.

func (*MockCoreServiceMockRecorder) TransactionLogByActionHash

func (mr *MockCoreServiceMockRecorder) TransactionLogByActionHash(actHash interface{}) *gomock.Call

TransactionLogByActionHash indicates an expected call of TransactionLogByActionHash.

func (*MockCoreServiceMockRecorder) TransactionLogByBlockHeight

func (mr *MockCoreServiceMockRecorder) TransactionLogByBlockHeight(blockHeight interface{}) *gomock.Call

TransactionLogByBlockHeight indicates an expected call of TransactionLogByBlockHeight.

func (*MockCoreServiceMockRecorder) UnconfirmedActionsByAddress

func (mr *MockCoreServiceMockRecorder) UnconfirmedActionsByAddress(address, start, count interface{}) *gomock.Call

UnconfirmedActionsByAddress indicates an expected call of UnconfirmedActionsByAddress.

func (*MockCoreServiceMockRecorder) WithHeight

func (mr *MockCoreServiceMockRecorder) WithHeight(arg0 interface{}) *gomock.Call

WithHeight indicates an expected call of WithHeight.

type MockCoreServiceReaderWithHeight

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

MockCoreServiceReaderWithHeight is a mock of CoreServiceReaderWithHeight interface.

func NewMockCoreServiceReaderWithHeight

func NewMockCoreServiceReaderWithHeight(ctrl *gomock.Controller) *MockCoreServiceReaderWithHeight

NewMockCoreServiceReaderWithHeight creates a new mock instance.

func (*MockCoreServiceReaderWithHeight) Account

Account mocks base method.

func (*MockCoreServiceReaderWithHeight) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockCoreServiceReaderWithHeight) ReadContract

ReadContract mocks base method.

type MockCoreServiceReaderWithHeightMockRecorder

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

MockCoreServiceReaderWithHeightMockRecorder is the mock recorder for MockCoreServiceReaderWithHeight.

func (*MockCoreServiceReaderWithHeightMockRecorder) Account

func (mr *MockCoreServiceReaderWithHeightMockRecorder) Account(arg0 interface{}) *gomock.Call

Account indicates an expected call of Account.

func (*MockCoreServiceReaderWithHeightMockRecorder) ReadContract

func (mr *MockCoreServiceReaderWithHeightMockRecorder) ReadContract(arg0, arg1, arg2 interface{}) *gomock.Call

ReadContract indicates an expected call of ReadContract.

type MockintrinsicGasCalculator

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

MockintrinsicGasCalculator is a mock of intrinsicGasCalculator interface.

func NewMockintrinsicGasCalculator

func NewMockintrinsicGasCalculator(ctrl *gomock.Controller) *MockintrinsicGasCalculator

NewMockintrinsicGasCalculator creates a new mock instance.

func (*MockintrinsicGasCalculator) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockintrinsicGasCalculator) IntrinsicGas

func (m *MockintrinsicGasCalculator) IntrinsicGas() (uint64, error)

IntrinsicGas mocks base method.

type MockintrinsicGasCalculatorMockRecorder

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

MockintrinsicGasCalculatorMockRecorder is the mock recorder for MockintrinsicGasCalculator.

func (*MockintrinsicGasCalculatorMockRecorder) IntrinsicGas

IntrinsicGas indicates an expected call of IntrinsicGas.

type Option

type Option func(cfg *coreService)

Option is the option to override the api config

func WithAPIStats

func WithAPIStats(stats *nodestats.APILocalStats) Option

WithAPIStats is the option to return RPC stats through API.

func WithArchiveSupport

func WithArchiveSupport() Option

WithArchiveSupport is the option to enable archive support

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

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 ServerV2

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

ServerV2 provides api for user to interact with blockchain data

func NewServerV2

func NewServerV2(
	cfg 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,
	_ evm.GetBlockTime,
	opts ...Option,
) (*ServerV2, error)

NewServerV2 creates a new server with coreService and GRPC Server

func (*ServerV2) CoreService

func (svr *ServerV2) CoreService() CoreService

CoreService returns the coreservice of the api

func (*ServerV2) ReceiveBlock

func (svr *ServerV2) ReceiveBlock(blk *block.Block) error

ReceiveBlock receives the new block

func (*ServerV2) Start

func (svr *ServerV2) Start(ctx context.Context) error

Start starts the CoreService and the GRPC server

func (*ServerV2) Stop

func (svr *ServerV2) Stop(ctx context.Context) error

Stop stops the GRPC server and the CoreService

type StreamBlocksServer

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

StreamBlocksServer defines the interface of a rpc stream server

type StreamContext

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

func StreamFromContext

func StreamFromContext(ctx context.Context) (*StreamContext, bool)

func (*StreamContext) AddListener

func (sc *StreamContext) AddListener(id string)

func (*StreamContext) ListenerIDs

func (sc *StreamContext) ListenerIDs() []string

func (*StreamContext) RemoveListener

func (sc *StreamContext) RemoveListener(id string)

type Web3Handler

type Web3Handler interface {
	HandlePOSTReq(context.Context, io.Reader, apitypes.Web3ResponseWriter) error
}

Web3Handler handle JRPC request

func NewWeb3Handler

func NewWeb3Handler(core CoreService, cacheURL string, batchRequestLimit int) Web3Handler

NewWeb3Handler creates a handle to process web3 requests

type WebsocketHandler

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

WebsocketHandler handles requests from websocket protocol

func NewWebsocketHandler

func NewWebsocketHandler(coreService CoreService, web3Handler Web3Handler, limiter *rate.Limiter) *WebsocketHandler

NewWebsocketHandler creates a new websocket handler

func (*WebsocketHandler) ServeHTTP

func (wsSvr *WebsocketHandler) ServeHTTP(w http.ResponseWriter, req *http.Request)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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