-
Notifications
You must be signed in to change notification settings - Fork 5
/
defaults.go
104 lines (92 loc) · 2.33 KB
/
defaults.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
package config
import (
"time"
)
// DefaultAppToken is the default token used for authenticating requests to the API
const DefaultAppToken = "mQZQ6WmxURxWz5ch" // #nosec G101
// GetDefaultAppConfig returns the default configuration for the application
func GetDefaultAppConfig() *AppConfig {
return &AppConfig{
Db: getDbDefaults(),
HTTP: getHTTPConfigDefaults(),
MerkleRoot: getMerkleRootDefaults(),
Websocket: getWebsocketDefaults(),
Webhook: getWebhookDefaults(),
P2P: getP2PDefaults(),
Logging: getLoggingDefaults(),
Metrics: getMetricsDefaults(),
}
}
func getDbDefaults() *DbConfig {
return &DbConfig{
Engine: DBSQLite,
SchemaPath: "./database/migrations",
PreparedDb: false,
PreparedDbFilePath: "./data/blockheaders.csv.gz",
SQLite: SQLiteConfig{
FilePath: "./data/blockheaders.db",
},
Postgres: getPostgresDefaults(),
}
}
func getHTTPConfigDefaults() *HTTPConfig {
return &HTTPConfig{
ReadTimeout: 10,
WriteTimeout: 10,
Port: 8080,
UseAuth: true,
AuthToken: DefaultAppToken,
ProfilingEndpointsEnabled: true,
}
}
func getMerkleRootDefaults() *MerkleRootConfig {
return &MerkleRootConfig{
MaxBlockHeightExcess: 6,
}
}
func getWebsocketDefaults() *WebsocketConfig {
return &WebsocketConfig{
HistoryMax: 300,
HistoryTTL: 10,
}
}
func getWebhookDefaults() *WebhookConfig {
return &WebhookConfig{
MaxTries: 10,
}
}
func getP2PDefaults() *P2PConfig {
return &P2PConfig{
BanDuration: time.Hour * 24,
BlocksForForkConfirmation: 10,
DefaultConnectTimeout: 30 * time.Second,
DisableCheckpoints: false,
UserAgentName: ApplicationName,
UserAgentVersion: Version(),
ChainNetType: MainNet,
Experimental: false,
}
}
func getLoggingDefaults() *LoggingConfig {
return &LoggingConfig{
Level: "debug",
Format: "console",
InstanceName: ApplicationName,
LogOrigin: true,
}
}
func getMetricsDefaults() *MetricsConfig {
return &MetricsConfig{
Enabled: false,
}
}
func getPostgresDefaults() PostgreSQLConfig {
return PostgreSQLConfig{
Host: "localhost",
Port: 5432,
User: "user",
Password: "password",
DbName: "bhs",
Sslmode: "disable",
}
}