arnaucube
arnaucube/hermez-nodePublic Self-hosted repository
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 getRecommendedFee(c *gin.Context) {
52
53}
54
55func retSQLErr(err error, c *gin.Context) {
56	if err == sql.ErrNoRows {
57		c.JSON(http.StatusNotFound, errorMsg{
58			Message: err.Error(),
59		})
60	} else {
61		c.JSON(http.StatusInternalServerError, errorMsg{
62			Message: err.Error(),
63		})
64	}
65}
66
67func retBadReq(err error, c *gin.Context) {
68	c.JSON(http.StatusBadRequest, errorMsg{
69		Message: err.Error(),
70	})
71}