mirror of
https://github.com/scroll-tech/scroll.git
synced 2026-01-14 16:37:56 -05:00
Co-authored-by: vincent <419436363@qq.com> Co-authored-by: georgehao <haohongfan@gmail.com> Co-authored-by: HAOYUatHZ <37070449+HAOYUatHZ@users.noreply.github.com>
69 lines
1.7 KiB
Go
69 lines
1.7 KiB
Go
package config
|
|
|
|
import (
|
|
"encoding/json"
|
|
"os"
|
|
"path/filepath"
|
|
)
|
|
|
|
type BatchInfoFetcherConfig struct {
|
|
BatchIndexStartBlock uint64 `json:"batchIndexStartBlock"`
|
|
ScrollChainAddr string `json:"ScrollChainAddr"`
|
|
}
|
|
|
|
// DBConfig db config
|
|
type DBConfig struct {
|
|
// data source name
|
|
DSN string `json:"dsn"`
|
|
DriverName string `json:"driverName"`
|
|
|
|
MaxOpenNum int `json:"maxOpenNum"`
|
|
MaxIdleNum int `json:"maxIdleNum"`
|
|
}
|
|
|
|
type LayerConfig struct {
|
|
Confirmation uint64 `json:"confirmation"`
|
|
Endpoint string `json:"endpoint"`
|
|
StartHeight uint64 `json:"startHeight"`
|
|
BlockTime int64 `json:"blockTime"`
|
|
MessengerAddr string `json:"MessengerAddr"`
|
|
ETHGatewayAddr string `json:"ETHGatewayAddr"`
|
|
WETHGatewayAddr string `json:"WETHGatewayAddr"`
|
|
StandardERC20Gateway string `json:"StandardERC20Gateway"`
|
|
ERC721GatewayAddr string `json:"ERC721GatewayAddr"`
|
|
ERC1155GatewayAddr string `json:"ERC1155GatewayAddr"`
|
|
CustomERC20GatewayAddr string `json:"CustomERC20GatewayAddr"`
|
|
}
|
|
|
|
type ServerConfig struct {
|
|
HostPort string `json:"hostPort"`
|
|
}
|
|
|
|
// Config is the configuration of the bridge history backend
|
|
type Config struct {
|
|
// chain config
|
|
L1 *LayerConfig `json:"l1"`
|
|
L2 *LayerConfig `json:"l2"`
|
|
|
|
// data source name
|
|
DB *DBConfig `json:"db"`
|
|
Server *ServerConfig `json:"server"`
|
|
BatchInfoFetcher *BatchInfoFetcherConfig `json:"batchInfoFetcher"`
|
|
}
|
|
|
|
// NewConfig returns a new instance of Config.
|
|
func NewConfig(file string) (*Config, error) {
|
|
buf, err := os.ReadFile(filepath.Clean(file))
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
cfg := &Config{}
|
|
err = json.Unmarshal(buf, cfg)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return cfg, nil
|
|
}
|