limiter

package
v1.30.0 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package limiter provides a rate limiting mechanism for RFQs to protect against reorgs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LatestBlockFetcher

type LatestBlockFetcher interface {
	// LatestBlock returns the latest block number.
	LatestBlock() uint64
}

LatestBlockFetcher is the interface for fetching the latest block number.

type Limiter

type Limiter interface {
	// IsAllowed returns true if the request is allowed, false otherwise.
	IsAllowed(ctx context.Context, request *reldb.QuoteRequest) (bool, error)
}

Limiter is the interface for rate limiting RFQs.

func NewRateLimiter

func NewRateLimiter(
	cfg relconfig.Config,
	l LatestBlockFetcher,
	q quoter.Quoter,
	metricHandler metrics.Handler,
	tokens map[string]relconfig.TokenConfig,
) Limiter

NewRateLimiter creates a new Limiter. TODO: implement the sliding window: queue up requests and process them in order if cumulative volume is above limit.

Jump to

Keyboard shortcuts

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