hermez-node/api/handlers.go
api/handlers.goRaw
1package api
2
3import (
4 "database/sql"
5 "errors"
6 "net/http"
7
8 "github.com/gin-gonic/gin"
9 "github.com/hermeznetwork/hermez-node/db/historydb"
10)
11
12const (
13 // maxLimit is the max permited items to be returned in paginated responses
14 maxLimit uint = 2049
15
16 // dfltOrder indicates how paginated endpoints are ordered if not specified
17 dfltOrder = historydb.OrderAsc
18
19 // dfltLimit indicates the limit of returned items in paginated responses if the query param limit is not provided
20 dfltLimit uint = 20
21
22 // 2^32 -1
23 maxUint32 = 4294967295
24)
25
26var (
27 // ErrNillBidderAddr is used when a nil bidderAddr is received in the getCoordinator method
28 ErrNillBidderAddr = errors.New("biderAddr can not be nil")
29)
30
31func getAccounts(c *gin.Context) {
32
33}
34
35func getAccount(c *gin.Context) {
36
37}
38
39func getSlots(c *gin.Context) {
40
41}
42
43func getNextForgers(c *gin.Context) {
44
45}
46
47func getState(c *gin.Context) {
48
49}
50
51func getConfig(c *gin.Context) {
52 c.JSON(http.StatusOK, cg)
53}
54
55func getRecommendedFee(c *gin.Context) {
56
57}
58
59func retSQLErr(err error, c *gin.Context) {
60 if err == sql.ErrNoRows {
61 c.JSON(http.StatusNotFound, errorMsg{
62 Message: err.Error(),
63 })
64 } else {
65 c.JSON(http.StatusInternalServerError, errorMsg{
66 Message: err.Error(),
67 })
68 }
69}
70
71func retBadReq(err error, c *gin.Context) {
72 c.JSON(http.StatusBadRequest, errorMsg{
73 Message: err.Error(),
74 })
75}