Skip to content

Commit

Permalink
Fix CI system for confiscation
Browse files Browse the repository at this point in the history
  • Loading branch information
galt-tr committed Feb 1, 2024
1 parent 65b972e commit e5da2b9
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
6 changes: 3 additions & 3 deletions app/api/base/alerts.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ import (
apirouter "github.com/mrz1836/go-api-router"
)

// HealthResponse is the response for the health endpoint
// AlertsResponse is the response for the alerts endpoint
type AlertsResponse struct {
Alerts []*models.AlertMessage `json:"alerts"`
LatestSequence uint32 `json:"latest_sequence"`
}

// health will return the health of the API and the current alert
// alerts will return the saved
func (a *Action) alerts(w http.ResponseWriter, req *http.Request, _ httprouter.Params) {

// Get the latest alert
// Get all alerts
alerts, err := models.GetAllAlerts(req.Context(), nil, model.WithAllDependencies(a.Config))
if err != nil {
app.APIErrorResponse(w, req, http.StatusBadRequest, err)
Expand Down
2 changes: 1 addition & 1 deletion app/models/alert_message.go
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ func GetLatestAlert(ctx context.Context, metadata *model.Metadata, opts ...model
return modelItems[0], nil
}

// GetAllAlerts
// GetAllAlerts returns all alerts in the database
func GetAllAlerts(ctx context.Context, metadata *model.Metadata, opts ...model.Options) ([]*AlertMessage, error) {
// Set the conditions
conditions := &map[string]interface{}{
Expand Down
7 changes: 6 additions & 1 deletion app/models/alert_message_confiscate_utxo.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"encoding/hex"
"errors"
"fmt"

"github.com/libsv/go-bn/models"
"github.com/libsv/go-p2p/wire"
)
Expand Down Expand Up @@ -68,9 +69,13 @@ func (a *AlertMessageConfiscateTransaction) Read(raw []byte) error {

// Do executes the alert
func (a *AlertMessageConfiscateTransaction) Do(ctx context.Context) error {
_, err := a.Config().Services.Node.AddToConfiscationTransactionWhitelist(ctx, a.Transactions)
res, err := a.Config().Services.Node.AddToConfiscationTransactionWhitelist(ctx, a.Transactions)
if err != nil {
return err
}
if len(res.NotProcessed) > 0 {
a.Config().Services.Log.Errorf("confiscation alert RPC response indicates it might have not been processed")
// TODO: I think we want to error here in the future so that the RPC call will be retried... but not clear right now
}
return nil
}
12 changes: 12 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: '3.8'

services:
alert-system:
image: docker.io/bsvb/alert-key:latest
user: root
environment:
- ALERT_SYSTEM_CONFIG_FILEPATH=/config.json
expose:
- "9908"
volumes:
- /home/galt/alert-key/config.json:/config.json:Z

0 comments on commit e5da2b9

Please sign in to comment.