-
Notifications
You must be signed in to change notification settings - Fork 84
/
Copy pathconfig.go
49 lines (45 loc) · 1.26 KB
/
config.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
38
39
40
41
42
43
44
45
46
47
48
49
package config
import "time"
type Config struct {
GenesisFilePath string `yaml:"genesis_file_path,omitempty"`
Workers int64 `yaml:"workers"`
StartHeight int64 `yaml:"start_height"`
AvgBlockTime *time.Duration `yaml:"average_block_time"`
ParseNewBlocks bool `yaml:"listen_new_blocks"`
ParseOldBlocks bool `yaml:"parse_old_blocks"`
ParseGenesis bool `yaml:"parse_genesis"`
FastSync bool `yaml:"fast_sync,omitempty"`
}
// NewParsingConfig allows to build a new Config instance
func NewParsingConfig(
workers int64,
parseNewBlocks, parseOldBlocks bool,
parseGenesis bool, genesisFilePath string,
startHeight int64, fastSync bool,
avgBlockTime *time.Duration,
) Config {
return Config{
Workers: workers,
ParseOldBlocks: parseOldBlocks,
ParseNewBlocks: parseNewBlocks,
ParseGenesis: parseGenesis,
GenesisFilePath: genesisFilePath,
StartHeight: startHeight,
FastSync: fastSync,
AvgBlockTime: avgBlockTime,
}
}
// DefaultParsingConfig returns the default instance of Config
func DefaultParsingConfig() Config {
avgBlockTime := 5 * time.Second
return NewParsingConfig(
1,
true,
true,
true,
"",
1,
false,
&avgBlockTime,
)
}