-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathconfig.go
More file actions
56 lines (44 loc) · 2.4 KB
/
config.go
File metadata and controls
56 lines (44 loc) · 2.4 KB
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
50
51
52
53
54
55
56
package bitcoin_reader
import (
"time"
"github.com/tokenized/config"
"github.com/tokenized/pkg/bitcoin"
)
type Config struct {
Network bitcoin.Network `default:"mainnet" json:"network" envconfig:"NETWORK"`
// Timeout is the amount of time a node will remain connected. This is to promote making new
// connections to keep a diverse set of peers.
Timeout config.Duration `default:"4h" json:"timeout" envconfig:"NODE_TIMEOUT"`
// ScanCount is the number of peer addresses that will be scanned for valid peers when a scan is
// performed.
ScanCount int `default:"100" json:"scan_count" envconfig:"SCAN_COUNT"`
// TxRequestCount is the maximum number of txs that will be requested from a node at one time.
TxRequestCount int `default:"10000" json:"tx_request_count" envconfig:"TX_REQUEST_COUNT"`
// StartupDelay delay after node manager startup before block processing will begin.
StartupDelay config.Duration `default:"1m" json:"startup_delay" envconfig:"STARTUP_DELAY"`
// ConcurrentBlockRequests is the number of concurrent block requests that will be attempted in
// case some of the requests are slow.
ConcurrentBlockRequests int `default:"2" json:"concurrent_block_requests" envconfig:"CONCURRENT_BLOCK_REQUESTS"`
// DesiredNodeCount is the number of node connectes that should be maintained.
DesiredNodeCount int `default:"50" json:"desired_node_count" envconfig:"DESIRED_NODE_COUNT"`
// StartBlockHeight is the block height at which blocks should be downloaded and processed.
// Only headers will be collected for blocks below that height.
StartBlockHeight int `default:"700000" json:"start_block_height" envconfig:"START_BLOCK_HEIGHT"`
// BlockRequestDelay is the delay between concurrent block requests. It should be long enough
// that small blocks will complete before the second request is made and only use concurrent
// requests for slow or large blocks.
BlockRequestDelay config.Duration `default:"30s" json:"block_request_delay" envconfig:"BLOCK_REQUEST_DELAY"`
}
func DefaultConfig() *Config {
return &Config{
Network: bitcoin.MainNet,
Timeout: config.NewDuration(time.Hour * 4),
ScanCount: 1000,
TxRequestCount: 10000,
StartupDelay: config.NewDuration(time.Minute),
ConcurrentBlockRequests: 2,
DesiredNodeCount: 50,
StartBlockHeight: 700000,
BlockRequestDelay: config.NewDuration(time.Second * 5),
}
}