resolver

package
v0.0.0-...-1bfa4a9 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2021 License: MIT Imports: 37 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LimiterDefaultGlobalRate = rate.Limit(1000)
	LimiterDefaultIPRate     = rate.Limit(10)
	LimiterDefaultTTL        = time.Minute
	LimiterDefaultMaxClients = 1000
)
View Source
const (
	MethodQueryTxsByTxid = "ren_queryTxsByTxid"
	MethodSubmitGateway  = "ren_submitGateway"
	MethodQueryGateway   = "ren_queryGateway"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type LightnodeRateLimiter

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

func NewRateLimiter

func NewRateLimiter(conf RateLimiterConf) LightnodeRateLimiter

func (*LightnodeRateLimiter) Allow

func (limiter *LightnodeRateLimiter) Allow(method string, ip net.IP) bool

Checks if the ip has an available limit, and increment if so Returns true if below limit, false otherwise

func (*LightnodeRateLimiter) Prune

func (limiter *LightnodeRateLimiter) Prune() int

Prune IP-addresses that have not been seen for a while.

type LightnodeValidator

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

The lightnode Validator checks requests and also casts in case of compat changes

func NewValidator

func NewValidator(network multichain.Network, bindings binding.Bindings, pubkey *id.PubKey, versionStore v0.CompatStore, gpubkeyStore v1.GpubkeyCompatStore, limiter *LightnodeRateLimiter, logger logrus.FieldLogger) *LightnodeValidator

func (*LightnodeValidator) ValidateRequest

func (validator *LightnodeValidator) ValidateRequest(ctx context.Context, r *http.Request, req jsonrpc.Request) (interface{}, jsonrpc.Response)

The validator usually checks if the params are in the correct shape for a given method We override the checker for certain methods here to cast invalid v0 params into v1 versions

type ParamsQueryGateway

type ParamsQueryGateway struct {
	Gateway string
}

type ParamsQueryTxByTxid

type ParamsQueryTxByTxid struct {
	Txid pack.Bytes
}

type ParamsSubmitGateway

type ParamsSubmitGateway struct {
	Tx      tx.Tx
	Gateway string
}

type PartialLockMintBurnReleaseInput

type PartialLockMintBurnReleaseInput struct {
	Payload pack.Bytes   `json:"payload"`
	Phash   pack.Bytes32 `json:"phash"`
	To      pack.String  `json:"to"`
	Nonce   pack.Bytes32 `json:"nonce"`
	Nhash   pack.Bytes32 `json:"nhash"`
	Gpubkey pack.Bytes   `json:"gpubkey"`
	Ghash   pack.Bytes32 `json:"ghash"`
}

PartialLockMintBurnReleaseInput is a subset of engine.LockMintBurnReleaseInput that is required to generate a gateway address

type RateLimiterConf

type RateLimiterConf struct {
	GlobalMethodRate map[string]rate.Limit
	IpMethodRate     map[string]rate.Limit
	Ttl              time.Duration
	MaxClients       int
}

func DefaultRateLimitConf

func DefaultRateLimitConf() RateLimiterConf

func NewRateLimitConf

func NewRateLimitConf(global rate.Limit, ip rate.Limit, ttl time.Duration, maxClients int) RateLimiterConf

type Resolver

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

func New

func New(network multichain.Network, logger logrus.FieldLogger, cacher phi.Task, multiStore store.MultiAddrStore, db db.DB,
	serverOptions jsonrpc.Options, versionStore v0.CompatStore, gpubkeyStore v1.GpubkeyCompatStore, bindings binding.Bindings, verifier Verifier) *Resolver

func (*Resolver) Fallback

func (resolver *Resolver) Fallback(ctx context.Context, id interface{}, method string, params interface{}, req *http.Request) jsonrpc.Response

func (*Resolver) QueryBlock

func (resolver *Resolver) QueryBlock(ctx context.Context, id interface{}, params *jsonrpc.ParamsQueryBlock, req *http.Request) jsonrpc.Response

func (*Resolver) QueryBlockState

func (resolver *Resolver) QueryBlockState(ctx context.Context, id interface{}, params *jsonrpc.ParamsQueryBlockState, req *http.Request) jsonrpc.Response

func (*Resolver) QueryBlocks

func (resolver *Resolver) QueryBlocks(ctx context.Context, id interface{}, params *jsonrpc.ParamsQueryBlocks, req *http.Request) jsonrpc.Response

func (*Resolver) QueryConfig

func (resolver *Resolver) QueryConfig(ctx context.Context, id interface{}, params *jsonrpc.ParamsQueryConfig, req *http.Request) jsonrpc.Response

func (*Resolver) QueryFees

func (resolver *Resolver) QueryFees(ctx context.Context, id interface{}, params *jsonrpc.ParamsQueryFees, req *http.Request) jsonrpc.Response

func (*Resolver) QueryGateway

func (resolver *Resolver) QueryGateway(ctx context.Context, id interface{}, params *ParamsQueryGateway, req *http.Request) jsonrpc.Response

Custom rpc for fetching gateways by address

func (*Resolver) QueryNumPeers

func (resolver *Resolver) QueryNumPeers(ctx context.Context, id interface{}, params *jsonrpc.ParamsQueryNumPeers, req *http.Request) jsonrpc.Response

func (*Resolver) QueryPeers

func (resolver *Resolver) QueryPeers(ctx context.Context, id interface{}, params *jsonrpc.ParamsQueryPeers, req *http.Request) jsonrpc.Response

func (*Resolver) QueryShards

func (resolver *Resolver) QueryShards(ctx context.Context, id interface{}, params *jsonrpc.ParamsQueryShards, req *http.Request) jsonrpc.Response

func (*Resolver) QueryStat

func (resolver *Resolver) QueryStat(ctx context.Context, id interface{}, params *jsonrpc.ParamsQueryStat, req *http.Request) jsonrpc.Response

func (*Resolver) QueryState

func (resolver *Resolver) QueryState(ctx context.Context, id interface{}, params *jsonrpc.ParamsQueryState, req *http.Request) jsonrpc.Response

func (*Resolver) QueryTx

func (resolver *Resolver) QueryTx(ctx context.Context, id interface{}, params *jsonrpc.ParamsQueryTx, req *http.Request) jsonrpc.Response

QueryTx either returns a locally cached result for confirming txs, or forwards and caches the request to the darknodes It will also detect if a tx is a v1 or v0 tx, and cast the response accordingly

func (*Resolver) QueryTxByTxid

func (resolver *Resolver) QueryTxByTxid(ctx context.Context, id interface{}, params *ParamsQueryTxByTxid, req *http.Request) jsonrpc.Response

Custom rpc for fetching transactions by txid

func (*Resolver) QueryTxs

func (resolver *Resolver) QueryTxs(ctx context.Context, id interface{}, params *jsonrpc.ParamsQueryTxs, req *http.Request) jsonrpc.Response

func (*Resolver) SubmitGateway

func (resolver *Resolver) SubmitGateway(ctx context.Context, id interface{}, params *ParamsSubmitGateway, req *http.Request) jsonrpc.Response

Custom rpc for storing gateway information NOTE: should be heavily rate-limited

func (*Resolver) SubmitTx

func (resolver *Resolver) SubmitTx(ctx context.Context, id interface{}, params *jsonrpc.ParamsSubmitTx, req *http.Request) jsonrpc.Response

type Verifier

type Verifier interface {
	VerifyTx(ctx context.Context, tx tx.Tx) error
}

func NewVerifier

func NewVerifier(hostChains map[multichain.Chain]bool, bindings binding.Bindings) Verifier

Jump to

Keyboard shortcuts

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