Skip to content

Commit

Permalink
rate limit
Browse files Browse the repository at this point in the history
  • Loading branch information
cryi committed Jun 21, 2024
1 parent 958051b commit 91f73c6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 15 deletions.
15 changes: 0 additions & 15 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,3 @@

- [ ] deploy
- [ ] prepare nginx config (I'll do this)

- [x] found bugs
- [x] tz1gXWW1q8NcXtVy2oVVcc2s4XKNzv9CryWd - 746 - minimum not found
- [x] tz1bZ8vsMAXmaWEV7FRnyhcuUs2fYMaQ6Hkk - 746 - minimum not found
- [ ] NOTE: waiting for confirmation from NL engineers

- [x] rolling/archive mode
- [x] configurable through configuration
- [x] implement rolling mode - remove cycles older than L - 20 where L is the last completed cycle (default)
- [x] implement archive mode - keep all cycles in the database

- [x] add consensus round delay - e.g. if 2 api returns for cycle 747 results of cycle 745
- [x] we should fetch it from network parameters when starting because it can be different on testnets

- [x] configurable subset of delegates to track instead of all so people can run their mirrors with reduced overhead
8 changes: 8 additions & 0 deletions api/public.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ import (
"errors"
"log/slog"
"strconv"
"time"

"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/limiter"
"github.com/tez-capital/ogun/configuration"
"github.com/tez-capital/ogun/constants"
"github.com/tez-capital/ogun/core"
Expand Down Expand Up @@ -113,6 +115,12 @@ func registerRewardsSplitMirror(app *fiber.App, engine *core.Engine) {

func CreatePublicApi(config *configuration.Runtime, engine *core.Engine) *fiber.App {
app := fiber.New()

app.Use(limiter.New(limiter.Config{
Max: 10,
Expiration: 30 * time.Second,
}))

registerGetDelegationState(app, engine)
registerIsDelegationStateAvailable(app, engine)
registerRewardsSplitMirror(app, engine)
Expand Down

0 comments on commit 91f73c6

Please sign in to comment.