From e5da2b9aba8f422d41348f7d74f62938797f108e Mon Sep 17 00:00:00 2001 From: Dylan Murray Date: Thu, 1 Feb 2024 13:35:39 -0500 Subject: [PATCH] Fix CI system for confiscation --- app/api/base/alerts.go | 6 +++--- app/models/alert_message.go | 2 +- app/models/alert_message_confiscate_utxo.go | 7 ++++++- docker-compose.yml | 12 ++++++++++++ 4 files changed, 22 insertions(+), 5 deletions(-) create mode 100644 docker-compose.yml diff --git a/app/api/base/alerts.go b/app/api/base/alerts.go index dc867ed..75259e8 100644 --- a/app/api/base/alerts.go +++ b/app/api/base/alerts.go @@ -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) diff --git a/app/models/alert_message.go b/app/models/alert_message.go index 8d4a215..599f5af 100644 --- a/app/models/alert_message.go +++ b/app/models/alert_message.go @@ -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{}{ diff --git a/app/models/alert_message_confiscate_utxo.go b/app/models/alert_message_confiscate_utxo.go index 3d418ee..443daf6 100644 --- a/app/models/alert_message_confiscate_utxo.go +++ b/app/models/alert_message_confiscate_utxo.go @@ -7,6 +7,7 @@ import ( "encoding/hex" "errors" "fmt" + "github.com/libsv/go-bn/models" "github.com/libsv/go-p2p/wire" ) @@ -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 } diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..d7815f8 --- /dev/null +++ b/docker-compose.yml @@ -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