Skip to content

Commit

Permalink
feat: add config for anchor db audit
Browse files Browse the repository at this point in the history
  • Loading branch information
smrz2001 committed Jul 31, 2023
1 parent cb96ca3 commit 3aed130
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 6 deletions.
18 changes: 12 additions & 6 deletions cmd/cas/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ func main() {
validationConsumer := queue.NewConsumer(logger, validateQueue, validationService.Validate, nil)

wg := sync.WaitGroup{}
wg.Add(3)
wg.Add(2)

// Set up graceful shutdown
go func() {
Expand Down Expand Up @@ -297,11 +297,17 @@ func main() {
batchingConsumer.Start()
validationConsumer.Start()

go func() {
defer wg.Done()
// Poll for requests that haven't been processed in time
services.NewRequestPoller(logger, anchorDb, stateDb, validateQueue, discordHandler).Run(serverCtx)
}()
// Enable auditing of the anchor DB to check for pending anchor requests that might have been missed
if configAnchorAuditEnabled, found := os.LookupEnv(models.Env_AnchorAuditEnabled); found {
if anchorAuditEnabled, err := strconv.ParseBool(configAnchorAuditEnabled); (err == nil) && anchorAuditEnabled {
wg.Add(1)
go func() {
defer wg.Done()
// Poll for requests that haven't been processed in time
services.NewRequestPoller(logger, anchorDb, stateDb, validateQueue, discordHandler).Run(serverCtx)
}()
}
}

wg.Wait()
}
1 change: 1 addition & 0 deletions env/.env.dev
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
ANCHOR_AUDIT_ENABLED=true
ANCHOR_BATCH_LINGER=5m
ANCHOR_BATCH_SIZE=1
ANCHOR_BATCH_MONITOR_TICK=10s
Expand Down
1 change: 1 addition & 0 deletions env/.env.prod
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
ANCHOR_AUDIT_ENABLED=false
ANCHOR_BATCH_LINGER=6h
ANCHOR_BATCH_SIZE=1024
ANCHOR_BATCH_MONITOR_TICK=10s
Expand Down
1 change: 1 addition & 0 deletions env/.env.qa
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
ANCHOR_AUDIT_ENABLED=true
ANCHOR_BATCH_LINGER=10s
ANCHOR_BATCH_SIZE=20
ANCHOR_BATCH_MONITOR_TICK=10s
Expand Down
1 change: 1 addition & 0 deletions env/.env.tnet
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
ANCHOR_AUDIT_ENABLED=true
ANCHOR_BATCH_LINGER=30m
ANCHOR_BATCH_SIZE=1024
ANCHOR_BATCH_MONITOR_TICK=10s
Expand Down
1 change: 1 addition & 0 deletions models/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const DefaultAnchorBatchSize = 1024
const DefaultAnchorBatchLinger = 12 * time.Hour

const (
Env_AnchorAuditEnabled = "ANCHOR_AUDIT_ENABLED"
Env_AnchorBatchSize = "ANCHOR_BATCH_SIZE"
Env_AnchorContractAddress = "ANCHOR_CONTRACT_ADDRESS"
)

0 comments on commit 3aed130

Please sign in to comment.