Documentation ¶
Index ¶
- Constants
- type LightnodeRateLimiter
- type LightnodeValidator
- type ParamsQueryGateway
- type ParamsQueryTxByTxid
- type ParamsSubmitGateway
- type PartialLockMintBurnReleaseInput
- type RateLimiterConf
- type Resolver
- func (resolver *Resolver) Fallback(ctx context.Context, id interface{}, method string, params interface{}, ...) jsonrpc.Response
- func (resolver *Resolver) QueryBlock(ctx context.Context, id interface{}, params *jsonrpc.ParamsQueryBlock, ...) jsonrpc.Response
- func (resolver *Resolver) QueryBlockState(ctx context.Context, id interface{}, params *jsonrpc.ParamsQueryBlockState, ...) jsonrpc.Response
- func (resolver *Resolver) QueryBlocks(ctx context.Context, id interface{}, params *jsonrpc.ParamsQueryBlocks, ...) jsonrpc.Response
- func (resolver *Resolver) QueryConfig(ctx context.Context, id interface{}, params *jsonrpc.ParamsQueryConfig, ...) jsonrpc.Response
- func (resolver *Resolver) QueryFees(ctx context.Context, id interface{}, params *jsonrpc.ParamsQueryFees, ...) jsonrpc.Response
- func (resolver *Resolver) QueryGateway(ctx context.Context, id interface{}, params *ParamsQueryGateway, ...) jsonrpc.Response
- func (resolver *Resolver) QueryNumPeers(ctx context.Context, id interface{}, params *jsonrpc.ParamsQueryNumPeers, ...) jsonrpc.Response
- func (resolver *Resolver) QueryPeers(ctx context.Context, id interface{}, params *jsonrpc.ParamsQueryPeers, ...) jsonrpc.Response
- func (resolver *Resolver) QueryShards(ctx context.Context, id interface{}, params *jsonrpc.ParamsQueryShards, ...) jsonrpc.Response
- func (resolver *Resolver) QueryStat(ctx context.Context, id interface{}, params *jsonrpc.ParamsQueryStat, ...) jsonrpc.Response
- func (resolver *Resolver) QueryState(ctx context.Context, id interface{}, params *jsonrpc.ParamsQueryState, ...) jsonrpc.Response
- func (resolver *Resolver) QueryTx(ctx context.Context, id interface{}, params *jsonrpc.ParamsQueryTx, ...) jsonrpc.Response
- func (resolver *Resolver) QueryTxByTxid(ctx context.Context, id interface{}, params *ParamsQueryTxByTxid, ...) jsonrpc.Response
- func (resolver *Resolver) QueryTxs(ctx context.Context, id interface{}, params *jsonrpc.ParamsQueryTxs, ...) jsonrpc.Response
- func (resolver *Resolver) SubmitGateway(ctx context.Context, id interface{}, params *ParamsSubmitGateway, ...) jsonrpc.Response
- func (resolver *Resolver) SubmitTx(ctx context.Context, id interface{}, params *jsonrpc.ParamsSubmitTx, ...) jsonrpc.Response
- type Verifier
Constants ¶
const ( LimiterDefaultGlobalRate = rate.Limit(1000) LimiterDefaultIPRate = rate.Limit(10) LimiterDefaultTTL = time.Minute LimiterDefaultMaxClients = 1000 )
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 ParamsSubmitGateway ¶
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 ¶
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) QueryBlock ¶
func (*Resolver) QueryBlockState ¶
func (*Resolver) QueryBlocks ¶
func (*Resolver) QueryConfig ¶
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) QueryPeers ¶
func (*Resolver) QueryShards ¶
func (*Resolver) QueryState ¶
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) 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