gateway

package
v1.29.2-rc1 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2024 License: Apache-2.0, MIT Imports: 47 Imported by: 8

Documentation

Index

Constants

View Source
const (
	DefaultMaxLookbackDuration      = time.Hour * 24     // Default duration that a gateway request can look back in chain history
	DefaultMaxMessageLookbackEpochs = abi.ChainEpoch(20) // Default number of epochs that a gateway message lookup can look back in chain history
	DefaultRateLimitTimeout         = time.Second * 5    // Default timeout for rate limiting requests; where a request would take longer to wait than this value, it will be retjected
	DefaultEthMaxFiltersPerConn     = 16                 // Default maximum number of ETH filters and subscriptions per websocket connection

	MaxRateLimitTokens = stateRateLimitTokens // Number of tokens consumed for the most expensive types of operations
)

Variables

View Source
var ErrTooManyFilters = errors.New("too many subscriptions and filters per connection")
View Source
var EthFeeHistoryMaxBlockCount = 128 // this seems to be expensive; todo: figure out what is a good number that works with everything

Functions

This section is empty.

Types

type EthSubHandler added in v1.20.0

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

func NewEthSubHandler added in v1.20.0

func NewEthSubHandler() *EthSubHandler

func (*EthSubHandler) AddSub added in v1.20.0

func (*EthSubHandler) EthSubscription added in v1.20.0

func (e *EthSubHandler) EthSubscription(ctx context.Context, r jsonrpc.RawParams) error

func (*EthSubHandler) RemoveSub added in v1.20.0

func (e *EthSubHandler) RemoveSub(id ethtypes.EthSubscriptionID)

type HandlerOption added in v1.29.0

type HandlerOption func(*handlerOptions)

HandlerOption is a functional option for configuring the Handler.

func WithJsonrpcServerOptions added in v1.29.0

func WithJsonrpcServerOptions(options ...jsonrpc.ServerOption) HandlerOption

WithJsonrpcServerOptions sets the JSON-RPC server options.

func WithPerConnectionAPIRateLimit added in v1.29.0

func WithPerConnectionAPIRateLimit(limit int) HandlerOption

WithPerConnectionAPIRateLimit sets the per connection API rate limit.

The handler will limit the number of API calls per minute within a single WebSocket connection (where API calls are weighted by their relative expense), and the number of connections per minute from a single host.

func WithPerHostConnectionsPerMinute added in v1.29.0

func WithPerHostConnectionsPerMinute(limit int) HandlerOption

WithPerHostConnectionsPerMinute sets the per host connections per minute limit.

Connection limiting is a hard limit that will reject requests with a http.StatusTooManyRequests status code if the limit is exceeded. API call limiting is a soft limit that will delay requests if the limit is exceeded.

type Node

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

func NewNode

func NewNode(api TargetAPI, opts ...Option) *Node

NewNode creates a new gateway node.

func (*Node) ChainGetBlock added in v1.23.3

func (gw *Node) ChainGetBlock(ctx context.Context, c cid.Cid) (*types.BlockHeader, error)

func (*Node) ChainGetBlockMessages

func (gw *Node) ChainGetBlockMessages(ctx context.Context, c cid.Cid) (*api.BlockMessages, error)

func (*Node) ChainGetEvents added in v1.26.0

func (gw *Node) ChainGetEvents(ctx context.Context, eventsRoot cid.Cid) ([]types.Event, error)

func (*Node) ChainGetGenesis added in v1.13.2

func (gw *Node) ChainGetGenesis(ctx context.Context) (*types.TipSet, error)

func (*Node) ChainGetMessage

func (gw *Node) ChainGetMessage(ctx context.Context, mc cid.Cid) (*types.Message, error)

func (*Node) ChainGetNode

func (gw *Node) ChainGetNode(ctx context.Context, p string) (*api.IpldObject, error)

func (*Node) ChainGetParentMessages added in v1.13.2

func (gw *Node) ChainGetParentMessages(ctx context.Context, c cid.Cid) ([]api.Message, error)

func (*Node) ChainGetParentReceipts added in v1.13.2

func (gw *Node) ChainGetParentReceipts(ctx context.Context, c cid.Cid) ([]*types.MessageReceipt, error)

func (*Node) ChainGetPath added in v1.11.3

func (gw *Node) ChainGetPath(ctx context.Context, from, to types.TipSetKey) ([]*api.HeadChange, error)

func (*Node) ChainGetTipSet

func (gw *Node) ChainGetTipSet(ctx context.Context, tsk types.TipSetKey) (*types.TipSet, error)

func (*Node) ChainGetTipSetAfterHeight added in v1.11.2

func (gw *Node) ChainGetTipSetAfterHeight(ctx context.Context, h abi.ChainEpoch, tsk types.TipSetKey) (*types.TipSet, error)

func (*Node) ChainGetTipSetByHeight

func (gw *Node) ChainGetTipSetByHeight(ctx context.Context, h abi.ChainEpoch, tsk types.TipSetKey) (*types.TipSet, error)

func (*Node) ChainHasObj

func (gw *Node) ChainHasObj(ctx context.Context, c cid.Cid) (bool, error)

func (*Node) ChainHead

func (gw *Node) ChainHead(ctx context.Context) (*types.TipSet, error)

func (*Node) ChainNotify

func (gw *Node) ChainNotify(ctx context.Context) (<-chan []*api.HeadChange, error)

func (*Node) ChainPutObj added in v1.16.0

func (gw *Node) ChainPutObj(context.Context, blocks.Block) error

func (*Node) ChainReadObj

func (gw *Node) ChainReadObj(ctx context.Context, c cid.Cid) ([]byte, error)

func (*Node) Discover added in v1.17.0

func (gw *Node) Discover(ctx context.Context) (apitypes.OpenRPCDocument, error)

func (*Node) EthAccounts added in v1.20.0

func (gw *Node) EthAccounts(ctx context.Context) ([]ethtypes.EthAddress, error)

func (*Node) EthAddressToFilecoinAddress added in v1.27.0

func (gw *Node) EthAddressToFilecoinAddress(ctx context.Context, ethAddress ethtypes.EthAddress) (address.Address, error)

func (*Node) EthBlockNumber added in v1.20.0

func (gw *Node) EthBlockNumber(ctx context.Context) (ethtypes.EthUint64, error)

func (*Node) EthCall added in v1.20.0

func (*Node) EthChainId added in v1.20.0

func (gw *Node) EthChainId(ctx context.Context) (ethtypes.EthUint64, error)

func (*Node) EthEstimateGas added in v1.20.0

func (gw *Node) EthEstimateGas(ctx context.Context, p jsonrpc.RawParams) (ethtypes.EthUint64, error)

func (*Node) EthFeeHistory added in v1.20.0

func (gw *Node) EthFeeHistory(ctx context.Context, p jsonrpc.RawParams) (ethtypes.EthFeeHistory, error)

func (*Node) EthGasPrice added in v1.20.0

func (gw *Node) EthGasPrice(ctx context.Context) (ethtypes.EthBigInt, error)

func (*Node) EthGetBalance added in v1.20.0

func (gw *Node) EthGetBalance(ctx context.Context, address ethtypes.EthAddress, blkParam ethtypes.EthBlockNumberOrHash) (ethtypes.EthBigInt, error)

func (*Node) EthGetBlockByHash added in v1.20.0

func (gw *Node) EthGetBlockByHash(ctx context.Context, blkHash ethtypes.EthHash, fullTxInfo bool) (ethtypes.EthBlock, error)

func (*Node) EthGetBlockByNumber added in v1.20.0

func (gw *Node) EthGetBlockByNumber(ctx context.Context, blkNum string, fullTxInfo bool) (ethtypes.EthBlock, error)

func (*Node) EthGetBlockReceipts added in v1.29.2

func (gw *Node) EthGetBlockReceipts(ctx context.Context, blkParam ethtypes.EthBlockNumberOrHash) ([]*api.EthTxReceipt, error)

func (*Node) EthGetBlockReceiptsLimited added in v1.29.2

func (gw *Node) EthGetBlockReceiptsLimited(ctx context.Context, blkParam ethtypes.EthBlockNumberOrHash, limit abi.ChainEpoch) ([]*api.EthTxReceipt, error)

func (*Node) EthGetBlockTransactionCountByHash added in v1.20.0

func (gw *Node) EthGetBlockTransactionCountByHash(ctx context.Context, blkHash ethtypes.EthHash) (ethtypes.EthUint64, error)

func (*Node) EthGetBlockTransactionCountByNumber added in v1.20.0

func (gw *Node) EthGetBlockTransactionCountByNumber(ctx context.Context, blkNum ethtypes.EthUint64) (ethtypes.EthUint64, error)

func (*Node) EthGetCode added in v1.20.0

func (gw *Node) EthGetCode(ctx context.Context, address ethtypes.EthAddress, blkParam ethtypes.EthBlockNumberOrHash) (ethtypes.EthBytes, error)

func (*Node) EthGetFilterChanges added in v1.20.0

func (gw *Node) EthGetFilterChanges(ctx context.Context, id ethtypes.EthFilterID) (*ethtypes.EthFilterResult, error)

func (*Node) EthGetFilterLogs added in v1.20.0

func (gw *Node) EthGetFilterLogs(ctx context.Context, id ethtypes.EthFilterID) (*ethtypes.EthFilterResult, error)

func (*Node) EthGetLogs added in v1.20.0

func (gw *Node) EthGetLogs(ctx context.Context, filter *ethtypes.EthFilterSpec) (*ethtypes.EthFilterResult, error)

func (*Node) EthGetMessageCidByTransactionHash added in v1.20.0

func (gw *Node) EthGetMessageCidByTransactionHash(ctx context.Context, txHash *ethtypes.EthHash) (*cid.Cid, error)

func (*Node) EthGetStorageAt added in v1.20.0

func (gw *Node) EthGetStorageAt(ctx context.Context, address ethtypes.EthAddress, position ethtypes.EthBytes, blkParam ethtypes.EthBlockNumberOrHash) (ethtypes.EthBytes, error)

func (*Node) EthGetTransactionByHash added in v1.20.0

func (gw *Node) EthGetTransactionByHash(ctx context.Context, txHash *ethtypes.EthHash) (*ethtypes.EthTx, error)

func (*Node) EthGetTransactionByHashLimited added in v1.23.0

func (gw *Node) EthGetTransactionByHashLimited(ctx context.Context, txHash *ethtypes.EthHash, limit abi.ChainEpoch) (*ethtypes.EthTx, error)

func (*Node) EthGetTransactionCount added in v1.20.0

func (gw *Node) EthGetTransactionCount(ctx context.Context, sender ethtypes.EthAddress, blkParam ethtypes.EthBlockNumberOrHash) (ethtypes.EthUint64, error)

func (*Node) EthGetTransactionHashByCid added in v1.20.0

func (gw *Node) EthGetTransactionHashByCid(ctx context.Context, cid cid.Cid) (*ethtypes.EthHash, error)

func (*Node) EthGetTransactionReceipt added in v1.20.0

func (gw *Node) EthGetTransactionReceipt(ctx context.Context, txHash ethtypes.EthHash) (*api.EthTxReceipt, error)

func (*Node) EthGetTransactionReceiptLimited added in v1.23.0

func (gw *Node) EthGetTransactionReceiptLimited(ctx context.Context, txHash ethtypes.EthHash, limit abi.ChainEpoch) (*api.EthTxReceipt, error)

func (*Node) EthMaxPriorityFeePerGas added in v1.20.0

func (gw *Node) EthMaxPriorityFeePerGas(ctx context.Context) (ethtypes.EthBigInt, error)

func (*Node) EthNewBlockFilter added in v1.20.0

func (gw *Node) EthNewBlockFilter(ctx context.Context) (ethtypes.EthFilterID, error)

func (*Node) EthNewFilter added in v1.20.0

func (gw *Node) EthNewFilter(ctx context.Context, filter *ethtypes.EthFilterSpec) (ethtypes.EthFilterID, error)

func (*Node) EthNewPendingTransactionFilter added in v1.20.0

func (gw *Node) EthNewPendingTransactionFilter(ctx context.Context) (ethtypes.EthFilterID, error)

func (*Node) EthProtocolVersion added in v1.20.0

func (gw *Node) EthProtocolVersion(ctx context.Context) (ethtypes.EthUint64, error)

func (*Node) EthSendRawTransaction added in v1.20.0

func (gw *Node) EthSendRawTransaction(ctx context.Context, rawTx ethtypes.EthBytes) (ethtypes.EthHash, error)

func (*Node) EthSubscribe added in v1.20.0

func (gw *Node) EthSubscribe(ctx context.Context, p jsonrpc.RawParams) (ethtypes.EthSubscriptionID, error)

func (*Node) EthSyncing added in v1.23.3

func (gw *Node) EthSyncing(ctx context.Context) (ethtypes.EthSyncingResult, error)

func (*Node) EthTraceBlock added in v1.25.0

func (gw *Node) EthTraceBlock(ctx context.Context, blkNum string) ([]*ethtypes.EthTraceBlock, error)

func (*Node) EthTraceFilter added in v1.29.0

func (gw *Node) EthTraceFilter(ctx context.Context, filter ethtypes.EthTraceFilterCriteria) ([]*ethtypes.EthTraceFilterResult, error)

func (*Node) EthTraceReplayBlockTransactions added in v1.25.0

func (gw *Node) EthTraceReplayBlockTransactions(ctx context.Context, blkNum string, traceTypes []string) ([]*ethtypes.EthTraceReplayBlockTransaction, error)

func (*Node) EthTraceTransaction added in v1.27.1

func (gw *Node) EthTraceTransaction(ctx context.Context, txHash string) ([]*ethtypes.EthTraceTransaction, error)

func (*Node) EthUninstallFilter added in v1.20.0

func (gw *Node) EthUninstallFilter(ctx context.Context, id ethtypes.EthFilterID) (bool, error)

func (*Node) EthUnsubscribe added in v1.20.0

func (gw *Node) EthUnsubscribe(ctx context.Context, id ethtypes.EthSubscriptionID) (bool, error)

func (*Node) FilecoinAddressToEthAddress added in v1.27.0

func (gw *Node) FilecoinAddressToEthAddress(ctx context.Context, params jsonrpc.RawParams) (ethtypes.EthAddress, error)

func (*Node) GasEstimateGasPremium added in v1.23.1

func (gw *Node) GasEstimateGasPremium(ctx context.Context, nblocksincl uint64, sender address.Address, gaslimit int64, tsk types.TipSetKey) (types.BigInt, error)

func (*Node) GasEstimateMessageGas

func (gw *Node) GasEstimateMessageGas(ctx context.Context, msg *types.Message, spec *api.MessageSendSpec, tsk types.TipSetKey) (*types.Message, error)

func (*Node) GetActorEventsRaw added in v1.26.0

func (gw *Node) GetActorEventsRaw(ctx context.Context, filter *types.ActorEventFilter) ([]*types.ActorEvent, error)

func (*Node) MinerGetBaseInfo added in v1.23.3

func (gw *Node) MinerGetBaseInfo(ctx context.Context, addr address.Address, h abi.ChainEpoch, tsk types.TipSetKey) (*api.MiningBaseInfo, error)

func (*Node) MpoolGetNonce added in v1.20.2

func (gw *Node) MpoolGetNonce(ctx context.Context, addr address.Address) (uint64, error)

func (*Node) MpoolPending added in v1.23.3

func (gw *Node) MpoolPending(ctx context.Context, tsk types.TipSetKey) ([]*types.SignedMessage, error)

func (*Node) MpoolPush

func (gw *Node) MpoolPush(ctx context.Context, sm *types.SignedMessage) (cid.Cid, error)

func (*Node) MsigGetAvailableBalance

func (gw *Node) MsigGetAvailableBalance(ctx context.Context, addr address.Address, tsk types.TipSetKey) (types.BigInt, error)

func (*Node) MsigGetPending

func (gw *Node) MsigGetPending(ctx context.Context, addr address.Address, tsk types.TipSetKey) ([]*api.MsigTransaction, error)

func (*Node) MsigGetVested

func (gw *Node) MsigGetVested(ctx context.Context, addr address.Address, start types.TipSetKey, end types.TipSetKey) (types.BigInt, error)

func (*Node) MsigGetVestingSchedule added in v1.15.1

func (gw *Node) MsigGetVestingSchedule(ctx context.Context, addr address.Address, tsk types.TipSetKey) (api.MsigVesting, error)

func (*Node) NetListening added in v1.20.0

func (gw *Node) NetListening(ctx context.Context) (bool, error)

func (*Node) NetVersion added in v1.20.0

func (gw *Node) NetVersion(ctx context.Context) (string, error)

func (*Node) StateAccountKey

func (gw *Node) StateAccountKey(ctx context.Context, addr address.Address, tsk types.TipSetKey) (address.Address, error)

func (*Node) StateCall added in v1.20.2

func (gw *Node) StateCall(ctx context.Context, msg *types.Message, tsk types.TipSetKey) (*api.InvocResult, error)

func (*Node) StateCirculatingSupply

func (gw *Node) StateCirculatingSupply(ctx context.Context, tsk types.TipSetKey) (abi.TokenAmount, error)

func (*Node) StateDealProviderCollateralBounds

func (gw *Node) StateDealProviderCollateralBounds(ctx context.Context, size abi.PaddedPieceSize, verified bool, tsk types.TipSetKey) (api.DealCollateralBounds, error)

func (*Node) StateDecodeParams added in v1.20.2

func (gw *Node) StateDecodeParams(ctx context.Context, toAddr address.Address, method abi.MethodNum, params []byte, tsk types.TipSetKey) (interface{}, error)

func (*Node) StateGetActor

func (gw *Node) StateGetActor(ctx context.Context, actor address.Address, tsk types.TipSetKey) (*types.Actor, error)

func (*Node) StateGetAllocation added in v1.25.0

func (gw *Node) StateGetAllocation(ctx context.Context, clientAddr address.Address, allocationId verifregtypes.AllocationId, tsk types.TipSetKey) (*verifregtypes.Allocation, error)

func (*Node) StateGetAllocationForPendingDeal added in v1.25.0

func (gw *Node) StateGetAllocationForPendingDeal(ctx context.Context, dealId abi.DealID, tsk types.TipSetKey) (*verifregtypes.Allocation, error)

func (*Node) StateGetAllocations added in v1.25.0

func (gw *Node) StateGetAllocations(ctx context.Context, clientAddr address.Address, tsk types.TipSetKey) (map[verifregtypes.AllocationId]verifregtypes.Allocation, error)

func (*Node) StateGetClaim added in v1.25.0

func (gw *Node) StateGetClaim(ctx context.Context, providerAddr address.Address, claimId verifregtypes.ClaimId, tsk types.TipSetKey) (*verifregtypes.Claim, error)

func (*Node) StateGetClaims added in v1.25.0

func (gw *Node) StateGetClaims(ctx context.Context, providerAddr address.Address, tsk types.TipSetKey) (map[verifregtypes.ClaimId]verifregtypes.Claim, error)

func (*Node) StateListMiners

func (gw *Node) StateListMiners(ctx context.Context, tsk types.TipSetKey) ([]address.Address, error)

func (*Node) StateLookupID

func (gw *Node) StateLookupID(ctx context.Context, addr address.Address, tsk types.TipSetKey) (address.Address, error)

func (*Node) StateMarketBalance

func (gw *Node) StateMarketBalance(ctx context.Context, addr address.Address, tsk types.TipSetKey) (api.MarketBalance, error)

func (*Node) StateMarketStorageDeal

func (gw *Node) StateMarketStorageDeal(ctx context.Context, dealId abi.DealID, tsk types.TipSetKey) (*api.MarketDeal, error)

func (*Node) StateMinerAvailableBalance

func (gw *Node) StateMinerAvailableBalance(ctx context.Context, m address.Address, tsk types.TipSetKey) (types.BigInt, error)

func (*Node) StateMinerDeadlines

func (gw *Node) StateMinerDeadlines(ctx context.Context, m address.Address, tsk types.TipSetKey) ([]api.Deadline, error)

func (*Node) StateMinerFaults

func (gw *Node) StateMinerFaults(ctx context.Context, m address.Address, tsk types.TipSetKey) (bitfield.BitField, error)

func (*Node) StateMinerInfo

func (gw *Node) StateMinerInfo(ctx context.Context, m address.Address, tsk types.TipSetKey) (api.MinerInfo, error)

func (*Node) StateMinerPower

func (gw *Node) StateMinerPower(ctx context.Context, m address.Address, tsk types.TipSetKey) (*api.MinerPower, error)

func (*Node) StateMinerProvingDeadline

func (gw *Node) StateMinerProvingDeadline(ctx context.Context, m address.Address, tsk types.TipSetKey) (*dline.Info, error)

func (*Node) StateMinerRecoveries

func (gw *Node) StateMinerRecoveries(ctx context.Context, m address.Address, tsk types.TipSetKey) (bitfield.BitField, error)

func (*Node) StateMinerSectorCount added in v1.23.1

func (gw *Node) StateMinerSectorCount(ctx context.Context, m address.Address, tsk types.TipSetKey) (api.MinerSectors, error)

func (*Node) StateNetworkName added in v1.20.2

func (gw *Node) StateNetworkName(ctx context.Context) (dtypes.NetworkName, error)

func (*Node) StateNetworkVersion

func (gw *Node) StateNetworkVersion(ctx context.Context, tsk types.TipSetKey) (network.Version, error)

func (*Node) StateReadState

func (gw *Node) StateReadState(ctx context.Context, actor address.Address, tsk types.TipSetKey) (*api.ActorState, error)

func (*Node) StateReplay added in v1.23.1

func (gw *Node) StateReplay(ctx context.Context, tsk types.TipSetKey, c cid.Cid) (*api.InvocResult, error)

func (*Node) StateSearchMsg

func (gw *Node) StateSearchMsg(ctx context.Context, from types.TipSetKey, msg cid.Cid, limit abi.ChainEpoch, allowReplaced bool) (*api.MsgLookup, error)

func (*Node) StateSectorGetInfo

func (gw *Node) StateSectorGetInfo(ctx context.Context, maddr address.Address, n abi.SectorNumber, tsk types.TipSetKey) (*miner.SectorOnChainInfo, error)

func (*Node) StateVMCirculatingSupplyInternal

func (gw *Node) StateVMCirculatingSupplyInternal(ctx context.Context, tsk types.TipSetKey) (api.CirculatingSupply, error)

func (*Node) StateVerifiedClientStatus

func (gw *Node) StateVerifiedClientStatus(ctx context.Context, addr address.Address, tsk types.TipSetKey) (*abi.StoragePower, error)

func (*Node) StateVerifierStatus added in v1.23.0

func (gw *Node) StateVerifierStatus(ctx context.Context, addr address.Address, tsk types.TipSetKey) (*abi.StoragePower, error)

func (*Node) StateWaitMsg

func (gw *Node) StateWaitMsg(ctx context.Context, msg cid.Cid, confidence uint64, limit abi.ChainEpoch, allowReplaced bool) (*api.MsgLookup, error)

func (*Node) SubscribeActorEventsRaw added in v1.26.0

func (gw *Node) SubscribeActorEventsRaw(ctx context.Context, filter *types.ActorEventFilter) (<-chan *types.ActorEvent, error)

func (*Node) Version

func (gw *Node) Version(ctx context.Context) (api.APIVersion, error)

func (*Node) WalletBalance

func (gw *Node) WalletBalance(ctx context.Context, k address.Address) (types.BigInt, error)

func (*Node) WalletVerify

func (gw *Node) WalletVerify(ctx context.Context, k address.Address, msg []byte, sig *crypto.Signature) (bool, error)

func (*Node) Web3ClientVersion added in v1.20.0

func (gw *Node) Web3ClientVersion(ctx context.Context) (string, error)

type Option added in v1.29.0

type Option func(*options)

func WithEthMaxFiltersPerConn added in v1.29.0

func WithEthMaxFiltersPerConn(ethMaxFiltersPerConn int) Option

WithEthMaxFiltersPerConn sets the maximum number of Ethereum filters and subscriptions that can be maintained per websocket connection.

func WithEthSubHandler added in v1.29.0

func WithEthSubHandler(subHandler *EthSubHandler) Option

WithEthSubHandler sets the Ethereum subscription handler for the gateway node. This is used for the RPC reverse handler for EthSubscribe calls.

func WithMaxLookbackDuration added in v1.29.0

func WithMaxLookbackDuration(maxLookbackDuration time.Duration) Option

WithMaxLookbackDuration sets the maximum lookback duration (time) for state queries.

func WithMaxMessageLookbackEpochs added in v1.29.0

func WithMaxMessageLookbackEpochs(maxMessageLookbackEpochs abi.ChainEpoch) Option

WithMaxMessageLookbackEpochs sets the maximum lookback (epochs) for state queries.

func WithRateLimit added in v1.29.0

func WithRateLimit(rateLimit int) Option

WithRateLimit sets the maximum number of requests per second globally that will be allowed before the gateway starts to rate limit requests.

func WithRateLimitTimeout added in v1.29.0

func WithRateLimitTimeout(rateLimitTimeout time.Duration) Option

WithRateLimitTimeout sets the timeout for rate limiting requests such that when rate limiting is being applied, if the timeout is reached the request will be allowed.

type RateLimitHandler added in v1.29.0

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

func NewRateLimitHandler added in v1.29.0

func NewRateLimitHandler(
	next http.Handler,
	perConnectionAPIRateLimit int,
	perHostConnectionsPerMinute int,
	cleanupInterval time.Duration,
) *RateLimitHandler

NewRateLimitHandler creates a new RateLimitHandler that wraps the provided handler and limits the number of API calls per minute within a single WebSocket connection (where API calls are weighted by their relative expense), and the number of connections per minute from a single host. The cleanupInterval determines how often the handler will check for unused limiters to clean up.

func (*RateLimitHandler) ServeHTTP added in v1.29.0

func (h *RateLimitHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*RateLimitHandler) Shutdown added in v1.29.0

func (h *RateLimitHandler) Shutdown(ctx context.Context) error

type ShutdownHandler added in v1.29.0

type ShutdownHandler interface {
	http.Handler

	Shutdown(ctx context.Context) error
}

ShutdownHandler is an http.Handler that can be gracefully shutdown.

func Handler

func Handler(gwapi lapi.Gateway, api lapi.FullNode, options ...HandlerOption) (ShutdownHandler, error)

Handler returns a gateway http.Handler, to be mounted as-is on the server. The handler is returned as a ShutdownHandler which allows for graceful shutdown of the handler via its Shutdown method.

type TargetAPI

type TargetAPI interface {
	MpoolPending(context.Context, types.TipSetKey) ([]*types.SignedMessage, error)
	ChainGetBlock(context.Context, cid.Cid) (*types.BlockHeader, error)
	MinerGetBaseInfo(context.Context, address.Address, abi.ChainEpoch, types.TipSetKey) (*api.MiningBaseInfo, error)
	GasEstimateGasPremium(context.Context, uint64, address.Address, int64, types.TipSetKey) (types.BigInt, error)
	StateReplay(context.Context, types.TipSetKey, cid.Cid) (*api.InvocResult, error)
	StateMinerSectorCount(context.Context, address.Address, types.TipSetKey) (api.MinerSectors, error)
	Version(context.Context) (api.APIVersion, error)
	ChainGetParentMessages(context.Context, cid.Cid) ([]api.Message, error)
	ChainGetParentReceipts(context.Context, cid.Cid) ([]*types.MessageReceipt, error)
	ChainGetBlockMessages(context.Context, cid.Cid) (*api.BlockMessages, error)
	ChainGetMessage(ctx context.Context, mc cid.Cid) (*types.Message, error)
	ChainGetNode(ctx context.Context, p string) (*api.IpldObject, error)
	ChainGetTipSet(ctx context.Context, tsk types.TipSetKey) (*types.TipSet, error)
	ChainGetTipSetByHeight(ctx context.Context, h abi.ChainEpoch, tsk types.TipSetKey) (*types.TipSet, error)
	ChainGetTipSetAfterHeight(ctx context.Context, h abi.ChainEpoch, tsk types.TipSetKey) (*types.TipSet, error)
	ChainHasObj(context.Context, cid.Cid) (bool, error)
	ChainHead(ctx context.Context) (*types.TipSet, error)
	ChainNotify(context.Context) (<-chan []*api.HeadChange, error)
	ChainGetPath(ctx context.Context, from, to types.TipSetKey) ([]*api.HeadChange, error)
	ChainReadObj(context.Context, cid.Cid) ([]byte, error)
	ChainPutObj(context.Context, blocks.Block) error
	ChainGetGenesis(context.Context) (*types.TipSet, error)
	GasEstimateMessageGas(ctx context.Context, msg *types.Message, spec *api.MessageSendSpec, tsk types.TipSetKey) (*types.Message, error)
	MpoolGetNonce(ctx context.Context, addr address.Address) (uint64, error)
	MpoolPushUntrusted(ctx context.Context, sm *types.SignedMessage) (cid.Cid, error)
	MsigGetAvailableBalance(ctx context.Context, addr address.Address, tsk types.TipSetKey) (types.BigInt, error)
	MsigGetVested(ctx context.Context, addr address.Address, start types.TipSetKey, end types.TipSetKey) (types.BigInt, error)
	MsigGetVestingSchedule(context.Context, address.Address, types.TipSetKey) (api.MsigVesting, error)
	MsigGetPending(ctx context.Context, addr address.Address, ts types.TipSetKey) ([]*api.MsigTransaction, error)
	StateAccountKey(ctx context.Context, addr address.Address, tsk types.TipSetKey) (address.Address, error)
	StateCall(ctx context.Context, msg *types.Message, tsk types.TipSetKey) (*api.InvocResult, error)
	StateDealProviderCollateralBounds(ctx context.Context, size abi.PaddedPieceSize, verified bool, tsk types.TipSetKey) (api.DealCollateralBounds, error)
	StateDecodeParams(ctx context.Context, toAddr address.Address, method abi.MethodNum, params []byte, tsk types.TipSetKey) (interface{}, error)
	StateGetActor(ctx context.Context, actor address.Address, ts types.TipSetKey) (*types.Actor, error)
	StateGetAllocationForPendingDeal(ctx context.Context, dealId abi.DealID, tsk types.TipSetKey) (*verifregtypes.Allocation, error)
	StateGetAllocation(ctx context.Context, clientAddr address.Address, allocationId verifregtypes.AllocationId, tsk types.TipSetKey) (*verifregtypes.Allocation, error)
	StateGetAllocations(ctx context.Context, clientAddr address.Address, tsk types.TipSetKey) (map[verifregtypes.AllocationId]verifregtypes.Allocation, error)
	StateGetClaim(ctx context.Context, providerAddr address.Address, claimId verifregtypes.ClaimId, tsk types.TipSetKey) (*verifregtypes.Claim, error)
	StateGetClaims(ctx context.Context, providerAddr address.Address, tsk types.TipSetKey) (map[verifregtypes.ClaimId]verifregtypes.Claim, error)
	StateLookupID(ctx context.Context, addr address.Address, tsk types.TipSetKey) (address.Address, error)
	StateListMiners(ctx context.Context, tsk types.TipSetKey) ([]address.Address, error)
	StateMarketBalance(ctx context.Context, addr address.Address, tsk types.TipSetKey) (api.MarketBalance, error)
	StateMarketStorageDeal(ctx context.Context, dealId abi.DealID, tsk types.TipSetKey) (*api.MarketDeal, error)
	StateNetworkName(context.Context) (dtypes.NetworkName, error)
	StateNetworkVersion(context.Context, types.TipSetKey) (network.Version, error)
	StateSearchMsg(ctx context.Context, from types.TipSetKey, msg cid.Cid, limit abi.ChainEpoch, allowReplaced bool) (*api.MsgLookup, error)
	StateWaitMsg(ctx context.Context, cid cid.Cid, confidence uint64, limit abi.ChainEpoch, allowReplaced bool) (*api.MsgLookup, error)
	StateReadState(ctx context.Context, actor address.Address, tsk types.TipSetKey) (*api.ActorState, error)
	StateMinerPower(context.Context, address.Address, types.TipSetKey) (*api.MinerPower, error)
	StateMinerFaults(context.Context, address.Address, types.TipSetKey) (bitfield.BitField, error)
	StateMinerRecoveries(context.Context, address.Address, types.TipSetKey) (bitfield.BitField, error)
	StateMinerInfo(context.Context, address.Address, types.TipSetKey) (api.MinerInfo, error)
	StateMinerDeadlines(context.Context, address.Address, types.TipSetKey) ([]api.Deadline, error)
	StateMinerAvailableBalance(context.Context, address.Address, types.TipSetKey) (types.BigInt, error)
	StateMinerProvingDeadline(context.Context, address.Address, types.TipSetKey) (*dline.Info, error)
	StateCirculatingSupply(context.Context, types.TipSetKey) (abi.TokenAmount, error)
	StateSectorGetInfo(ctx context.Context, maddr address.Address, n abi.SectorNumber, tsk types.TipSetKey) (*miner.SectorOnChainInfo, error)
	StateVerifiedClientStatus(ctx context.Context, addr address.Address, tsk types.TipSetKey) (*abi.StoragePower, error)
	StateVerifierStatus(ctx context.Context, addr address.Address, tsk types.TipSetKey) (*abi.StoragePower, error)
	StateVMCirculatingSupplyInternal(context.Context, types.TipSetKey) (api.CirculatingSupply, error)
	WalletBalance(context.Context, address.Address) (types.BigInt, error)

	EthAddressToFilecoinAddress(ctx context.Context, ethAddress ethtypes.EthAddress) (address.Address, error)
	FilecoinAddressToEthAddress(ctx context.Context, p jsonrpc.RawParams) (ethtypes.EthAddress, error)
	EthBlockNumber(ctx context.Context) (ethtypes.EthUint64, error)
	EthGetBlockTransactionCountByNumber(ctx context.Context, blkNum ethtypes.EthUint64) (ethtypes.EthUint64, error)
	EthGetBlockTransactionCountByHash(ctx context.Context, blkHash ethtypes.EthHash) (ethtypes.EthUint64, error)
	EthGetBlockByHash(ctx context.Context, blkHash ethtypes.EthHash, fullTxInfo bool) (ethtypes.EthBlock, error)
	EthGetBlockByNumber(ctx context.Context, blkNum string, fullTxInfo bool) (ethtypes.EthBlock, error)
	EthGetTransactionByHashLimited(ctx context.Context, txHash *ethtypes.EthHash, limit abi.ChainEpoch) (*ethtypes.EthTx, error)
	EthGetTransactionHashByCid(ctx context.Context, cid cid.Cid) (*ethtypes.EthHash, error)
	EthGetMessageCidByTransactionHash(ctx context.Context, txHash *ethtypes.EthHash) (*cid.Cid, error)
	EthGetTransactionCount(ctx context.Context, sender ethtypes.EthAddress, blkParam ethtypes.EthBlockNumberOrHash) (ethtypes.EthUint64, error)
	EthGetTransactionReceiptLimited(ctx context.Context, txHash ethtypes.EthHash, limit abi.ChainEpoch) (*api.EthTxReceipt, error)
	EthGetTransactionByBlockHashAndIndex(ctx context.Context, blkHash ethtypes.EthHash, txIndex ethtypes.EthUint64) (ethtypes.EthTx, error)
	EthGetTransactionByBlockNumberAndIndex(ctx context.Context, blkNum ethtypes.EthUint64, txIndex ethtypes.EthUint64) (ethtypes.EthTx, error)
	EthGetCode(ctx context.Context, address ethtypes.EthAddress, blkParam ethtypes.EthBlockNumberOrHash) (ethtypes.EthBytes, error)
	EthGetStorageAt(ctx context.Context, address ethtypes.EthAddress, position ethtypes.EthBytes, blkParam ethtypes.EthBlockNumberOrHash) (ethtypes.EthBytes, error)
	EthGetBalance(ctx context.Context, address ethtypes.EthAddress, blkParam ethtypes.EthBlockNumberOrHash) (ethtypes.EthBigInt, error)
	EthChainId(ctx context.Context) (ethtypes.EthUint64, error)
	EthSyncing(ctx context.Context) (ethtypes.EthSyncingResult, error)
	NetVersion(ctx context.Context) (string, error)
	NetListening(ctx context.Context) (bool, error)
	EthProtocolVersion(ctx context.Context) (ethtypes.EthUint64, error)
	EthGasPrice(ctx context.Context) (ethtypes.EthBigInt, error)
	EthFeeHistory(ctx context.Context, p jsonrpc.RawParams) (ethtypes.EthFeeHistory, error)
	EthMaxPriorityFeePerGas(ctx context.Context) (ethtypes.EthBigInt, error)
	EthEstimateGas(ctx context.Context, p jsonrpc.RawParams) (ethtypes.EthUint64, error)
	EthCall(ctx context.Context, tx ethtypes.EthCall, blkParam ethtypes.EthBlockNumberOrHash) (ethtypes.EthBytes, error)
	EthSendRawTransaction(ctx context.Context, rawTx ethtypes.EthBytes) (ethtypes.EthHash, error)
	EthGetLogs(ctx context.Context, filter *ethtypes.EthFilterSpec) (*ethtypes.EthFilterResult, error)
	EthGetFilterChanges(ctx context.Context, id ethtypes.EthFilterID) (*ethtypes.EthFilterResult, error)
	EthGetFilterLogs(ctx context.Context, id ethtypes.EthFilterID) (*ethtypes.EthFilterResult, error)
	EthNewFilter(ctx context.Context, filter *ethtypes.EthFilterSpec) (ethtypes.EthFilterID, error)
	EthNewBlockFilter(ctx context.Context) (ethtypes.EthFilterID, error)
	EthNewPendingTransactionFilter(ctx context.Context) (ethtypes.EthFilterID, error)
	EthUninstallFilter(ctx context.Context, id ethtypes.EthFilterID) (bool, error)
	EthSubscribe(ctx context.Context, params jsonrpc.RawParams) (ethtypes.EthSubscriptionID, error)
	EthUnsubscribe(ctx context.Context, id ethtypes.EthSubscriptionID) (bool, error)
	Web3ClientVersion(ctx context.Context) (string, error)
	EthTraceBlock(ctx context.Context, blkNum string) ([]*ethtypes.EthTraceBlock, error)
	EthTraceReplayBlockTransactions(ctx context.Context, blkNum string, traceTypes []string) ([]*ethtypes.EthTraceReplayBlockTransaction, error)
	EthTraceTransaction(ctx context.Context, txHash string) ([]*ethtypes.EthTraceTransaction, error)
	EthTraceFilter(ctx context.Context, filter ethtypes.EthTraceFilterCriteria) ([]*ethtypes.EthTraceFilterResult, error)
	EthGetBlockReceiptsLimited(ctx context.Context, blkParam ethtypes.EthBlockNumberOrHash, limit abi.ChainEpoch) ([]*api.EthTxReceipt, error)
	EthGetBlockReceipts(ctx context.Context, blkParam ethtypes.EthBlockNumberOrHash) ([]*api.EthTxReceipt, error)
	GetActorEventsRaw(ctx context.Context, filter *types.ActorEventFilter) ([]*types.ActorEvent, error)
	SubscribeActorEventsRaw(ctx context.Context, filter *types.ActorEventFilter) (<-chan *types.ActorEvent, error)
	ChainGetEvents(ctx context.Context, eventsRoot cid.Cid) ([]types.Event, error)
}

TargetAPI defines the API methods that the Node depends on (to make it easy to mock for tests)

Jump to

Keyboard shortcuts

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