Documentation ¶
Index ¶
- type RateLimiter
- func NewCancelOrderRateLimiter(config types.BlockRateLimitConfiguration) RateLimiter[*types.MsgCancelOrder]
- func NewMultiBlockRateLimiter[K comparable](context string, config []types.MaxPerNBlocksRateLimit) RateLimiter[K]
- func NewNoOpRateLimiter[K any]() RateLimiter[K]
- func NewPanicRateLimiter[K any]() RateLimiter[K]
- func NewPlaceOrderRateLimiter(config types.BlockRateLimitConfiguration) RateLimiter[*types.MsgPlaceOrder]
- func NewSingleBlockRateLimiter[K comparable](context string, config types.MaxPerNBlocksRateLimit) RateLimiter[K]
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RateLimiter ¶
type RateLimiter[K any] interface { // Returns an error if the RateLimiter exceeds any configured rate limits for the key K and context state. RateLimit(ctx sdk.Context, key K) error // Prunes rate limits for the provided context. PruneRateLimits(ctx sdk.Context) }
Used to RateLimit for a key K.
func NewCancelOrderRateLimiter ¶
func NewCancelOrderRateLimiter(config types.BlockRateLimitConfiguration) RateLimiter[*types.MsgCancelOrder]
NewCancelOrderRateLimiter returns a RateLimiter which rate limits types.MsgCancelOrder based upon the provided types.BlockRateLimitConfiguration. The rate limiter currently supports limiting based upon:
- how many short term order cancellations per subaccount (by using satypes.SubaccountId).
The rate limiting keeps track of order cancellations placed during CheckTx.
Depending upon the provided types.BlockRateLimitConfiguration, the returned RateLimiter may rely on:
- `ctx.BlockHeight()` in RateLimit to track which block the rate limit should apply to.
- `ctx.BlockHeight()` in PruneRateLimits and should be invoked during `EndBlocker`. If invoked during `PrepareCheckState` one must supply a `ctx` with the previous block height via `ctx.WithBlockHeight(ctx.BlockHeight()-1)`.
func NewMultiBlockRateLimiter ¶
func NewMultiBlockRateLimiter[K comparable](context string, config []types.MaxPerNBlocksRateLimit) RateLimiter[K]
Returns a RateLimiter over multiple blocks.
`ctx.BlockHeight()` is used in RateLimit to track which block the rate limit should apply to.
`ctx.BlockHeight()` is used in PruneRateLimits to remove rate limits for a block `maxNumBlocks` ago. If invoked during `EndBlocker` then you can pass in the `ctx` as is but if invoked during `PrepareCheckState` one must supply a `ctx` with the previous block height via `ctx.WithBlockHeight(ctx.BlockHeight()-1)`.
func NewNoOpRateLimiter ¶
func NewNoOpRateLimiter[K any]() RateLimiter[K]
Returns a RateLimiter that does not enforce any limits.
func NewPanicRateLimiter ¶
func NewPanicRateLimiter[K any]() RateLimiter[K]
Returns a RateLimiter that will panic on invocation.
func NewPlaceOrderRateLimiter ¶
func NewPlaceOrderRateLimiter(config types.BlockRateLimitConfiguration) RateLimiter[*types.MsgPlaceOrder]
NewPlaceOrderRateLimiter returns a RateLimiter which rate limits types.MsgPlaceOrder based upon the provided types.BlockRateLimitConfiguration. The rate limiter currently supports limiting based upon:
- how many short term orders per subaccount (by using satypes.SubaccountId).
- how many stateful order per subaccount (by using satypes.SubaccountId).
The rate limiting keeps track of orders placed during CheckTx separately from when they are placed during DeliverTx modes.
Depending upon the provided types.BlockRateLimitConfiguration, the returned RateLimiter may rely on:
- `ctx.BlockHeight()` in RateLimit to track which block the rate limit should apply to.
- `ctx.BlockHeight()` in PruneRateLimits and should be invoked during `EndBlocker`. If invoked during `PrepareCheckState` one must supply a `ctx` with the previous block height via `ctx.WithBlockHeight(ctx.BlockHeight()-1)`.
func NewSingleBlockRateLimiter ¶
func NewSingleBlockRateLimiter[K comparable](context string, config types.MaxPerNBlocksRateLimit) RateLimiter[K]