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 // 2^64 /2 -1
26 maxInt64 = 9223372036854775807
27)
28
29var (
30 // ErrNillBidderAddr is used when a nil bidderAddr is received in the getCoordinator method
31 ErrNillBidderAddr = errors.New("biderAddr can not be nil")
32)
33
34func getAccounts(c *gin.Context) {
35
36}
37
38func getAccount(c *gin.Context) {
39
40}
41
42func getNextForgers(c *gin.Context) {
43
44}
45
46func getState(c *gin.Context) {
47
48}
49
50func getRecommendedFee(c *gin.Context) {
51
52}
53
54func retSQLErr(err error, c *gin.Context) {
55 if err == sql.ErrNoRows {
56 c.JSON(http.StatusNotFound, errorMsg{
57 Message: err.Error(),
58 })
59 } else {
60 c.JSON(http.StatusInternalServerError, errorMsg{
61 Message: err.Error(),
62 })
63 }
64}
65
66func retBadReq(err error, c *gin.Context) {
67 c.JSON(http.StatusBadRequest, errorMsg{
68 Message: err.Error(),
69 })
70}