-
Notifications
You must be signed in to change notification settings - Fork 199
/
configParser.go
37 lines (31 loc) · 1.05 KB
/
configParser.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package core
import (
logger "github.com/ElrondNetwork/elrond-go-logger"
"github.com/ElrondNetwork/elrond-go/config"
)
var log = logger.GetOrCreate("core")
// LoadP2PConfig returns a P2PConfig by reading the config file provided
func LoadP2PConfig(filepath string) (*config.P2PConfig, error) {
cfg := &config.P2PConfig{}
err := LoadTomlFile(cfg, filepath)
if err != nil {
return nil, err
}
return cfg, nil
}
// LoadGasScheduleConfig returns a map[string]uint64 of gas costs read from the provided config file
func LoadGasScheduleConfig(filepath string) (map[string]map[string]uint64, error) {
gasScheduleConfig, err := LoadTomlFileToMap(filepath)
if err != nil {
return nil, err
}
flattenedGasSchedule := make(map[string]map[string]uint64)
for libType, costs := range gasScheduleConfig {
flattenedGasSchedule[libType] = make(map[string]uint64)
costsMap := costs.(map[string]interface{})
for operationName, cost := range costsMap {
flattenedGasSchedule[libType][operationName] = uint64(cost.(int64))
}
}
return flattenedGasSchedule, nil
}