Add blockchain config to Config struct

This commit is contained in:
ChronosX88 2021-05-26 23:59:05 +03:00
parent 155fe7bc71
commit 1759ecbc8f
Signed by: ChronosXYZ
GPG Key ID: 085A69A82C8C511A

View File

@ -7,18 +7,19 @@ import (
) )
type Config struct { type Config struct {
ListenPort int `mapstructure:"listen_port"` ListenPort int `mapstructure:"listen_port"`
ListenAddr string `mapstructure:"listen_addr"` ListenAddr string `mapstructure:"listen_addr"`
IsBootstrap bool `mapstructure:"is_bootstrap"` IsBootstrap bool `mapstructure:"is_bootstrap"`
BootstrapNodes []string `mapstructure:"bootstrap_node_multiaddr"` BootstrapNodes []string `mapstructure:"bootstrap_node_multiaddr"`
Rendezvous string `mapstructure:"rendezvous"` Rendezvous string `mapstructure:"rendezvous"`
Ethereum EthereumConfig `mapstructure:"ethereum"` Ethereum EthereumConfig `mapstructure:"ethereum"`
Filecoin FilecoinConfig `mapstructure:"filecoin"` Filecoin FilecoinConfig `mapstructure:"filecoin"`
PubSub PubSubConfig `mapstructure:"pubSub"` PubSub PubSubConfig `mapstructure:"pubsub"`
Store StoreConfig `mapstructure:"store"` Store StoreConfig `mapstructure:"store"`
ConsensusMinApprovals int `mapstructure:"consensus_min_approvals"` ConsensusMinApprovals int `mapstructure:"consensus_min_approvals"`
Redis RedisConfig `mapstructure:"redis"` Redis RedisConfig `mapstructure:"redis"`
CacheType string `mapstructure:"cache_type"` CacheType string `mapstructure:"cache_type"`
Blockchain BlockchainConfig `mapstructure:"blockchain"`
} }
type EthereumConfig struct { type EthereumConfig struct {
@ -39,8 +40,7 @@ type FilecoinConfig struct {
} }
type PubSubConfig struct { type PubSubConfig struct {
ProtocolID string `mapstructure:"protocolID"` ServiceTopicName string `mapstructure:"service_topic_name"`
ServiceTopicName string `mapstructure:"serviceTopicName"`
} }
type StoreConfig struct { type StoreConfig struct {
@ -53,6 +53,10 @@ type RedisConfig struct {
DB int `mapstructure:"redis_db"` DB int `mapstructure:"redis_db"`
} }
type BlockchainConfig struct {
DatabasePath string `mapstructure:"database_path"`
}
// NewConfig creates a new config based on default values or provided .env file // NewConfig creates a new config based on default values or provided .env file
func NewConfig(configPath string) (*Config, error) { func NewConfig(configPath string) (*Config, error) {
dbName := "dione" dbName := "dione"
@ -64,12 +68,12 @@ func NewConfig(configPath string) (*Config, error) {
ListenAddr: "localhost", ListenAddr: "localhost",
ListenPort: 8000, ListenPort: 8000,
BootstrapNodes: []string{"/ip4/127.0.0.1/tcp/0"}, BootstrapNodes: []string{"/ip4/127.0.0.1/tcp/0"},
Rendezvous: "filecoin-p2p-oracle", Rendezvous: "dione",
Ethereum: EthereumConfig{ Ethereum: EthereumConfig{
PrivateKey: "", PrivateKey: "",
}, },
PubSub: PubSubConfig{ PubSub: PubSubConfig{
ProtocolID: "p2p-oracle", ServiceTopicName: "dione",
}, },
Store: StoreConfig{ Store: StoreConfig{
DatabaseURL: dbURL, DatabaseURL: dbURL,