mirror of
https://github.com/arnaucube/hermez-node.git
synced 2026-02-07 03:16:45 +01:00
WIP
This commit is contained in:
@@ -144,10 +144,15 @@ func cmdRun(c *cli.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func cmdServeAPI(c *cli.Context) error {
|
func cmdServeAPI(c *cli.Context) error {
|
||||||
cfg, err := parseCli(c)
|
cfgPath := c.String(flagCfg)
|
||||||
|
cfg, err := config.LoadAPIServer(cfgPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
if err := cli.ShowAppHelp(c); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
return tracerr.Wrap(fmt.Errorf("error parsing flags and config: %w", err))
|
return tracerr.Wrap(fmt.Errorf("error parsing flags and config: %w", err))
|
||||||
}
|
}
|
||||||
|
|
||||||
node, err := node.NewNode(cfg.mode, cfg.node)
|
node, err := node.NewNode(cfg.mode, cfg.node)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return tracerr.Wrap(fmt.Errorf("error starting node: %w", err))
|
return tracerr.Wrap(fmt.Errorf("error starting node: %w", err))
|
||||||
@@ -261,9 +266,6 @@ func getConfig(c *cli.Context) (*Config, error) {
|
|||||||
var cfg Config
|
var cfg Config
|
||||||
mode := c.String(flagMode)
|
mode := c.String(flagMode)
|
||||||
nodeCfgPath := c.String(flagCfg)
|
nodeCfgPath := c.String(flagCfg)
|
||||||
if nodeCfgPath == "" {
|
|
||||||
return nil, tracerr.Wrap(fmt.Errorf("required flag \"%v\" not set", flagCfg))
|
|
||||||
}
|
|
||||||
var err error
|
var err error
|
||||||
switch mode {
|
switch mode {
|
||||||
case modeSync:
|
case modeSync:
|
||||||
|
|||||||
@@ -334,6 +334,17 @@ type APIServer struct {
|
|||||||
Coordinator bool
|
Coordinator bool
|
||||||
} `validate:"required"`
|
} `validate:"required"`
|
||||||
} `validate:"required"`
|
} `validate:"required"`
|
||||||
|
L2DB struct {
|
||||||
|
// MaxTxs is the maximum number of pending L2Txs that can be
|
||||||
|
// stored in the pool. Once this number of pending L2Txs is
|
||||||
|
// reached, inserts to the pool will be denied until some of
|
||||||
|
// the pending txs are forged.
|
||||||
|
MaxTxs uint32 `validate:"required"`
|
||||||
|
// MinFeeUSD is the minimum fee in USD that a tx must pay in
|
||||||
|
// order to be accepted into the pool. Txs with lower than
|
||||||
|
// minimum fee will be rejected at the API level.
|
||||||
|
MinFeeUSD float64
|
||||||
|
} `validate:"required"`
|
||||||
Debug NodeDebug `validate:"required"`
|
Debug NodeDebug `validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -378,3 +389,16 @@ func LoadNode(path string) (*Node, error) {
|
|||||||
}
|
}
|
||||||
return &cfg, nil
|
return &cfg, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// LoadAPIServer loads the APIServer configuration from path.
|
||||||
|
func LoadAPIServer(path string) (*APIServer, error) {
|
||||||
|
var cfg APIServer
|
||||||
|
if err := Load(path, &cfg); err != nil {
|
||||||
|
return nil, tracerr.Wrap(fmt.Errorf("error loading apiServer configuration file: %w", err))
|
||||||
|
}
|
||||||
|
validate := validator.New()
|
||||||
|
if err := validate.Struct(cfg); err != nil {
|
||||||
|
return nil, tracerr.Wrap(fmt.Errorf("error validating configuration file: %w", err))
|
||||||
|
}
|
||||||
|
return &cfg, nil
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user