kadena-io / chainweb-data

Data ingestion for Chainweb.
BSD 3-Clause "New" or "Revised" License
14 stars 8 forks source link

Limit offset on event endpoint #107

Closed emmanueldenloye closed 1 year ago

enobayram commented 1 year ago

Here's how I verified this PR:

A search request without offset:

$ curl -v "<cwd-url>/txs/events?limit=1&search="
...
< HTTP/1.1 200 OK
...
[{"blockTime":"2022-12-09T22:38:16.375796Z","height":3273169,"blockHash":"x52kDb3IhT1hOGRp2U3Jn5---z5mkYUfDZonyWEExkI","requestKey":"<coinbase>","params":["","k:8372f0a8661247e39971ff2551a5e95de4110b8c090f5ddd93eb6fbb7d13d732",1.0354825],"name":"coin.TRANSFER","idx":0,"chain":0,"moduleHash":"rE7DU8jlQL9x_MPYuniZJf5ICBTAEHAIFQCB4blofP4"}]

One with an acceptable offset:

$ curl -v "<cwd-url>/txs/events?limit=1&offset=10&search="
...
< HTTP/1.1 200 OK
...
[{"blockTime":"2022-12-09T22:40:42.184803Z","height":3273174,"blockHash":"pa6hYt6IdOeCpCUbO_cZIlf7f7SijNWtB7Lp1QSTB2o","requestKey":"XNSiIaYIKLkR_i-KEgMCWIQ19kpVJSG8Gl6Q8JtB9FA","params":["k:1f41ee69271c3f10374272d8c9fea0eae454d30af90ab72ac5f5796ed3c0bf57","99cb7008d7d70c94f138cc366a825f0d9c83a8a2f4ba82c86c666e0ab6fecf3a",1.0e-3],"name":"coin.TRANSFER","idx":0,"chain":0,"moduleHash":"rE7DU8jlQL9x_MPYuniZJf5ICBTAEHAIFQCB4blofP4"}]

One with an unacceptably large offset:

$ curl -v "http://node.defunctional.com:1849/txs/events?limit=1&offset=1000000&search="
...
< HTTP/1.1 400 Bad Request
...
the maximum allowed offset is 10,000. You requested 1000000