mirror of
https://github.com/eosswedenorg/thalos
synced 2026-06-18 04:40:03 +02:00
Formatting fix.
This commit is contained in:
parent
953113b456
commit
1e2dda54c8
9 changed files with 440 additions and 448 deletions
|
|
@ -1,63 +1,61 @@
|
|||
|
||||
package config
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"encoding/json"
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
)
|
||||
|
||||
const NULL_BLOCK_NUMBER uint32 = 0xffffffff
|
||||
|
||||
type RedisConfig struct {
|
||||
Addr string `json:"addr"`
|
||||
Password string `json:"password"`
|
||||
DB int `json:db`
|
||||
CacheID string `json:"cache_id"`
|
||||
Addr string `json:"addr"`
|
||||
Password string `json:"password"`
|
||||
DB int `json:db`
|
||||
CacheID string `json:"cache_id"`
|
||||
}
|
||||
|
||||
type TelegramConfig struct {
|
||||
Id string `json:"id"`
|
||||
Channel int64 `json:"channel"`
|
||||
Id string `json:"id"`
|
||||
Channel int64 `json:"channel"`
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
Name string `json:"name"`
|
||||
ShipApi string `json:"ship_api"`
|
||||
Api string `json:"api"`
|
||||
Name string `json:"name"`
|
||||
ShipApi string `json:"ship_api"`
|
||||
Api string `json:"api"`
|
||||
|
||||
Redis RedisConfig `json:"redis"`
|
||||
Redis RedisConfig `json:"redis"`
|
||||
|
||||
Telegram TelegramConfig `json:"telegram"`
|
||||
Telegram TelegramConfig `json:"telegram"`
|
||||
|
||||
IrreversibleOnly bool `json:"irreversible_only"`
|
||||
MaxMessagesInFlight uint32 `json:"max_messages_in_flight"`
|
||||
StartBlockNum uint32 `json:"start_block_num"`
|
||||
EndBlockNum uint32 `json:"end_block_num"`
|
||||
IrreversibleOnly bool `json:"irreversible_only"`
|
||||
MaxMessagesInFlight uint32 `json:"max_messages_in_flight"`
|
||||
StartBlockNum uint32 `json:"start_block_num"`
|
||||
EndBlockNum uint32 `json:"end_block_num"`
|
||||
}
|
||||
|
||||
func Load(filename string) (Config, error) {
|
||||
cfg := Config{
|
||||
StartBlockNum: NULL_BLOCK_NUMBER,
|
||||
EndBlockNum: NULL_BLOCK_NUMBER,
|
||||
MaxMessagesInFlight: 10,
|
||||
IrreversibleOnly: false,
|
||||
Redis: RedisConfig{
|
||||
Addr: "localhost:6379",
|
||||
Password: "",
|
||||
DB: 0,
|
||||
},
|
||||
}
|
||||
|
||||
cfg := Config{
|
||||
StartBlockNum: NULL_BLOCK_NUMBER,
|
||||
EndBlockNum: NULL_BLOCK_NUMBER,
|
||||
MaxMessagesInFlight: 10,
|
||||
IrreversibleOnly: false,
|
||||
Redis: RedisConfig{
|
||||
Addr: "localhost:6379",
|
||||
Password: "",
|
||||
DB: 0,
|
||||
},
|
||||
}
|
||||
bytes, err := ioutil.ReadFile(filename)
|
||||
if err != nil {
|
||||
return cfg, err
|
||||
}
|
||||
|
||||
bytes, err := ioutil.ReadFile(filename)
|
||||
if err != nil {
|
||||
return cfg, err
|
||||
}
|
||||
err = json.Unmarshal(bytes, &cfg)
|
||||
if err != nil {
|
||||
return cfg, err
|
||||
}
|
||||
|
||||
err = json.Unmarshal(bytes, &cfg)
|
||||
if err != nil {
|
||||
return cfg, err
|
||||
}
|
||||
|
||||
return cfg, nil
|
||||
return cfg, nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue