Skip to content

Commit 6347b0b

Browse files
committed
Minor updates, formatting, name changes
1 parent 986d3f7 commit 6347b0b

7 files changed

Lines changed: 74 additions & 19 deletions

File tree

config/config.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const (
2727
EnvironmentStaging = "staging"
2828
EnvironmentTest = "test"
2929
HealthRequestPath = "health"
30-
Version = "v0.1.4"
30+
Version = "v0.1.5"
3131
)
3232

3333
// Local variables for configuration
@@ -58,7 +58,7 @@ type (
5858
Mongo *datastore.MongoDBConfig `json:"mongodb" mapstructure:"mongodb"`
5959
Monitor *MonitorOptions `json:"monitor" mapstructure:"monitor"`
6060
NewRelic *NewRelicConfig `json:"new_relic" mapstructure:"new_relic"`
61-
Notifications *NotificationsConfig `json:"notifications" mapstructure:"notifications"`
61+
Notifications *NotificationsConfig `json:"notifications" mapstructure:"notifications"`
6262
Paymail *PaymailConfig `json:"paymail" mapstructure:"paymail"`
6363
Redis *RedisConfig `json:"redis" mapstructure:"redis"`
6464
RequestLogging bool `json:"request_logging" mapstructure:"request_logging"`
@@ -99,17 +99,17 @@ type (
9999

100100
// MonitorOptions is the configuration for blockchain monitoring
101101
MonitorOptions struct {
102+
AuthToken string `json:"auth_token" mapstructure:"auth_token"` // Token to connect to the server with
103+
CentrifugeServerURL string `json:"centrifuge_server_url" mapstructure:"centrifuge_server_url"` // The server url address
102104
Debug bool `json:"debug" mapstructure:"debug"` // true/false
103105
Enabled bool `json:"enabled" mapstructure:"enabled"` // true/false
104-
CentrifugeServer string `json:"centrifuge_server" mapstructure:"centrifuge_server"` // The server url address
105-
Token string `json:"token" mapstructure:"token"` // Token to connect to the server with
106-
MonitorDays int `json:"monitor_days" mapstructure:"monitor_days"` // how many days in the past should we monitor an address (default: 7)
107106
FalsePositiveRate float64 `json:"false_positive_rate" mapstructure:"false_positive_rate"` // how many false positives do we except (default: 0.01)
108-
SaveTransactionDestinations bool `json:"save_transaction_destinations" mapstructure:"save_transaction_destinations"` // Whether to save destinations on monitored transactions
109-
ProcessorType string `json:"processor_type" mapstructure:"processor_type"` // Type of processor to start monitor with. Default: bloom
110-
LoadMonitoredDestinations bool `json:"load_monitored_destinations" mapstructure:"load_monitored_destinations"` // Whehter to load monitored destinations`
107+
LoadMonitoredDestinations bool `json:"load_monitored_destinations" mapstructure:"load_monitored_destinations"` // Whether to load monitored destinations`
111108
MaxNumberOfDestinations int `json:"max_number_of_destinations" mapstructure:"max_number_of_destinations"` // how many destinations can the filter hold (default: 100,000)
109+
MonitorDays int `json:"monitor_days" mapstructure:"monitor_days"` // how many days in the past should we monitor an address (default: 7)
112110
ProcessMempoolOnConnect bool `json:"process_mempool_on_connect" mapstructure:"process_mempool_on_connect"` // Whether to process all transactions in the mempool when connecting to centrifuge server
111+
ProcessorType string `json:"processor_type" mapstructure:"processor_type"` // Type of processor to start monitor with. Default: bloom
112+
SaveTransactionDestinations bool `json:"save_transaction_destinations" mapstructure:"save_transaction_destinations"` // Whether to save destinations on monitored transactions
113113
}
114114

115115
// NewRelicConfig is the configuration for New Relic

config/envs/development.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
},
3434
"monitor": {
3535
"enabled": true,
36-
"centrifuge_server": "ws://localhost:8000/websocket",
37-
"token": "",
36+
"centrifuge_server_url": "ws://localhost:8000/websocket",
37+
"auth_token": "",
3838
"processMempoolOnConnect": true,
3939
"load_monitored_destinations": false,
4040
"save_destinations": true

config/envs/docker-compose.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@
3232
"transactions": false,
3333
"uri": "mongodb://localhost:27017/bux"
3434
},
35+
"monitor": {
36+
"enabled": true,
37+
"centrifuge_server_url": "ws://localhost:8000/websocket",
38+
"auth_token": "",
39+
"processMempoolOnConnect": true,
40+
"load_monitored_destinations": false,
41+
"save_destinations": true
42+
},
3543
"new_relic": {
3644
"domain_name": "domain.com",
3745
"enabled": false,

config/envs/production.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@
3232
"transactions": false,
3333
"uri": "mongodb://localhost:27017/bux"
3434
},
35+
"monitor": {
36+
"enabled": true,
37+
"centrifuge_server_url": "ws://localhost:8000/websocket",
38+
"auth_token": "",
39+
"processMempoolOnConnect": true,
40+
"load_monitored_destinations": false,
41+
"save_destinations": true
42+
},
3543
"new_relic": {
3644
"domain_name": "domain.com",
3745
"enabled": true,

config/envs/staging.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@
3232
"transactions": false,
3333
"uri": "mongodb://localhost:27017/bux"
3434
},
35+
"monitor": {
36+
"enabled": true,
37+
"centrifuge_server_url": "ws://localhost:8000/websocket",
38+
"auth_token": "",
39+
"processMempoolOnConnect": true,
40+
"load_monitored_destinations": false,
41+
"save_destinations": true
42+
},
3543
"new_relic": {
3644
"domain_name": "domain.com",
3745
"enabled": true,

config/envs/test.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@
3737
"enabled": false,
3838
"license_key": "BOGUS-LICENSE-KEY-1234567890987654321234"
3939
},
40+
"monitor": {
41+
"enabled": false,
42+
"centrifuge_server_url": "ws://localhost:8000/websocket",
43+
"auth_token": "",
44+
"processMempoolOnConnect": true,
45+
"load_monitored_destinations": false,
46+
"save_destinations": true
47+
},
4048
"paymail": {
4149
"enabled": false,
4250
"default_from_paymail": "from@domain.com",

config/services.go

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -204,26 +204,26 @@ func (s *AppServices) loadBux(ctx context.Context, appConfig *AppConfig) (err er
204204
}
205205
}
206206

207+
// Load the notifications
207208
if appConfig.Notifications != nil && appConfig.Notifications.Enabled {
208-
// configure the default notification handler
209209
options = append(options, bux.WithNotifications(appConfig.Notifications.WebhookEndpoint))
210210
}
211211

212+
// Load the monitor
212213
if appConfig.Monitor != nil && appConfig.Monitor.Enabled {
213-
if appConfig.Monitor.CentrifugeServer == "" {
214-
err = errors.New("CentrifugeServer is required for monitoring to work")
215-
return
214+
if appConfig.Monitor.CentrifugeServerURL == "" {
215+
return errors.New("CentrifugeServerURL is required for monitoring to work")
216216
}
217217
options = append(options, bux.WithMonitoring(ctx, &chainstate.MonitorOptions{
218+
CentrifugeServer: appConfig.Monitor.CentrifugeServerURL,
218219
Debug: appConfig.Monitor.Debug,
219-
CentrifugeServer: appConfig.Monitor.CentrifugeServer,
220-
MonitorDays: appConfig.Monitor.MonitorDays,
221-
Token: appConfig.Monitor.Token,
222220
FalsePositiveRate: appConfig.Monitor.FalsePositiveRate,
223-
MaxNumberOfDestinations: appConfig.Monitor.MaxNumberOfDestinations,
224-
SaveTransactionDestinations: appConfig.Monitor.SaveTransactionDestinations,
225221
LoadMonitoredDestinations: appConfig.Monitor.LoadMonitoredDestinations,
222+
MaxNumberOfDestinations: appConfig.Monitor.MaxNumberOfDestinations,
223+
MonitorDays: appConfig.Monitor.MonitorDays,
226224
ProcessMempoolOnConnect: appConfig.Monitor.ProcessMempoolOnConnect,
225+
SaveTransactionDestinations: appConfig.Monitor.SaveTransactionDestinations,
226+
Token: appConfig.Monitor.AuthToken,
227227
}))
228228
}
229229

@@ -280,6 +280,29 @@ func (s *AppServices) loadTestBux(ctx context.Context, appConfig *AppConfig) (er
280280
return err
281281
}
282282

283+
// Load the notifications
284+
if appConfig.Notifications != nil && appConfig.Notifications.Enabled {
285+
options = append(options, bux.WithNotifications(appConfig.Notifications.WebhookEndpoint))
286+
}
287+
288+
// Load the monitor
289+
if appConfig.Monitor != nil && appConfig.Monitor.Enabled {
290+
if appConfig.Monitor.CentrifugeServerURL == "" {
291+
return errors.New("CentrifugeServerURL is required for monitoring to work")
292+
}
293+
options = append(options, bux.WithMonitoring(ctx, &chainstate.MonitorOptions{
294+
CentrifugeServer: appConfig.Monitor.CentrifugeServerURL,
295+
Debug: appConfig.Monitor.Debug,
296+
FalsePositiveRate: appConfig.Monitor.FalsePositiveRate,
297+
LoadMonitoredDestinations: appConfig.Monitor.LoadMonitoredDestinations,
298+
MaxNumberOfDestinations: appConfig.Monitor.MaxNumberOfDestinations,
299+
MonitorDays: appConfig.Monitor.MonitorDays,
300+
ProcessMempoolOnConnect: appConfig.Monitor.ProcessMempoolOnConnect,
301+
SaveTransactionDestinations: appConfig.Monitor.SaveTransactionDestinations,
302+
Token: appConfig.Monitor.AuthToken,
303+
}))
304+
}
305+
283306
// Create the client
284307
s.Bux, err = bux.NewClient(ctx, options...)
285308

0 commit comments

Comments
 (0)