ipld-eth-state-snapshot/pkg/snapshot/config.go

59 lines
1.9 KiB
Go
Raw Normal View History

2020-07-01 18:44:59 +00:00
// Copyright © 2020 Vulcanize, Inc
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package snapshot
import (
"github.com/spf13/viper"
"github.com/vulcanize/ipfs-blockchain-watcher/pkg/config"
"github.com/vulcanize/ipfs-blockchain-watcher/pkg/core"
)
const (
2020-08-03 15:46:35 +00:00
ANCIENT_DB_PATH = "ANCIENT_DB_PATH"
2020-07-01 18:44:59 +00:00
ETH_CLIENT_NAME = "ETH_CLIENT_NAME"
ETH_GENESIS_BLOCK = "ETH_GENESIS_BLOCK"
ETH_NETWORK_ID = "ETH_NETWORK_ID"
2020-08-03 15:46:35 +00:00
ETH_NODE_ID = "ETH_NODE_ID"
LVL_DB_PATH = "LVL_DB_PATH"
2020-07-01 18:44:59 +00:00
)
2020-08-20 10:23:36 +00:00
type ServiceConfig struct {
2020-08-03 15:46:35 +00:00
LevelDBPath string
AncientDBPath string
Node core.Node
DBConfig config.Database
2020-07-01 18:44:59 +00:00
}
2020-08-20 10:23:36 +00:00
func (c *ServiceConfig) Init() {
2020-07-01 18:44:59 +00:00
c.DBConfig.Init()
viper.BindEnv("leveldb.path", LVL_DB_PATH)
viper.BindEnv("ethereum.nodeID", ETH_NODE_ID)
viper.BindEnv("ethereum.clientName", ETH_CLIENT_NAME)
viper.BindEnv("ethereum.genesisBlock", ETH_GENESIS_BLOCK)
viper.BindEnv("ethereum.networkID", ETH_NETWORK_ID)
2020-08-03 15:46:35 +00:00
viper.BindEnv("leveldb.ancient", ANCIENT_DB_PATH)
2020-07-01 18:44:59 +00:00
c.Node = core.Node{
ID: viper.GetString("ethereum.nodeID"),
ClientName: viper.GetString("ethereum.clientName"),
GenesisBlock: viper.GetString("ethereum.genesisBlock"),
NetworkID: viper.GetString("ethereum.networkID"),
}
c.LevelDBPath = viper.GetString("leveldb.path")
2020-08-03 15:46:35 +00:00
c.AncientDBPath = viper.GetString("leveldb.ancient")
2020-07-01 18:44:59 +00:00
}