arnaucube
arnaucube/hermez-nodePublic Self-hosted repository
hermez-node/api/config.go
api/config.goRaw
 1package api
 2
 3import (
 4	"math/big"
 5	"net/http"
 6
 7	"github.com/gin-gonic/gin"
 8	"github.com/hermeznetwork/hermez-node/common"
 9)
10
11type rollupConstants struct {
12	PublicConstants         common.RollupConstants `json:"publicConstants"`
13	MaxFeeIdxCoordinator    int                    `json:"maxFeeIdxCoordinator"`
14	ReservedIdx             int                    `json:"reservedIdx"`
15	ExitIdx                 int                    `json:"exitIdx"`
16	LimitLoadAmount         *big.Int               `json:"limitLoadAmount"`
17	LimitL2TransferAmount   *big.Int               `json:"limitL2TransferAmount"`
18	LimitTokens             int                    `json:"limitTokens"`
19	L1CoordinatorTotalBytes int                    `json:"l1CoordinatorTotalBytes"`
20	L1UserTotalBytes        int                    `json:"l1UserTotalBytes"`
21	MaxL1UserTx             int                    `json:"maxL1UserTx"`
22	MaxL1Tx                 int                    `json:"maxL1Tx"`
23	InputSHAConstantBytes   int                    `json:"inputSHAConstantBytes"`
24	NumBuckets              int                    `json:"numBuckets"`
25	MaxWithdrawalDelay      int                    `json:"maxWithdrawalDelay"`
26	ExchangeMultiplier      int                    `json:"exchangeMultiplier"`
27}
28
29func newRollupConstants(publicConstants common.RollupConstants) *rollupConstants {
30	return &rollupConstants{
31		PublicConstants:         publicConstants,
32		MaxFeeIdxCoordinator:    common.RollupConstMaxFeeIdxCoordinator,
33		ReservedIdx:             common.RollupConstReservedIDx,
34		ExitIdx:                 common.RollupConstExitIDx,
35		LimitLoadAmount:         common.RollupConstLimitLoadAmount,
36		LimitL2TransferAmount:   common.RollupConstLimitL2TransferAmount,
37		LimitTokens:             common.RollupConstLimitTokens,
38		L1CoordinatorTotalBytes: common.RollupConstL1CoordinatorTotalBytes,
39		L1UserTotalBytes:        common.RollupConstL1UserTotalBytes,
40		MaxL1UserTx:             common.RollupConstMaxL1UserTx,
41		MaxL1Tx:                 common.RollupConstMaxL1Tx,
42		InputSHAConstantBytes:   common.RollupConstInputSHAConstantBytes,
43		NumBuckets:              common.RollupConstNumBuckets,
44		MaxWithdrawalDelay:      common.RollupConstMaxWithdrawalDelay,
45		ExchangeMultiplier:      common.RollupConstExchangeMultiplier,
46	}
47}
48
49// Config of the API
50type Config struct {
51	RollupConstants   common.RollupConstants
52	AuctionConstants  common.AuctionConstants
53	WDelayerConstants common.WDelayerConstants
54}
55
56type configAPI struct {
57	RollupConstants   rollupConstants          `json:"hermez"`
58	AuctionConstants  common.AuctionConstants  `json:"auction"`
59	WDelayerConstants common.WDelayerConstants `json:"withdrawalDelayer"`
60}
61
62func (a *API) getConfig(c *gin.Context) {
63	c.JSON(http.StatusOK, a.cg)
64}