Skip to content

Commit

Permalink
fix: fix race condition caused by the gb (maybe)
Browse files Browse the repository at this point in the history
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
  • Loading branch information
vincenzopalazzo committed Jan 31, 2023
1 parent 0c98b7e commit f5999d9
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions internal/metrics/metrics_one.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,17 +379,20 @@ func (instance *RawLocalScore) InitOnRepo(client *graphql.Client, lightning cln4

// UploadOnRepo Contact the server and make an update request
func (instance *RawLocalScore) UploadOnRepo(client *graphql.Client, lightning cln4go.Client) error {
payload, err := instance.ToJSON()
// This method is called after we run the update event
// and we clean up the instance after storing the result
// inside the database.
payload, err := instance.Storage.LoadLastMetricOne()
if err != nil {
return err
}
toSign := sha256.SHA256(&payload)
toSign := sha256.SHA256(payload)
log.GetInstance().Info(fmt.Sprintf("Hash of the paylad: %s", toSign))
signPayload, err := ln.SignMessage(lightning, &toSign)
if err != nil {
return err
}
if err := client.UploadMetric(instance.NodeID, &payload, signPayload.ZBase); err != nil {
if err := client.UploadMetric(instance.NodeID, payload, signPayload.ZBase); err != nil {
log.GetInstance().Errorf("Error: %s", err)
return err
}
Expand Down

0 comments on commit f5999d9

Please sign in to comment.