Skip to content

Commit

Permalink
fix: tracking job offer update events (#194)
Browse files Browse the repository at this point in the history
* chore: no need to fetch the evn var everytime

* chore: remove job offer update subscription

* fix: track job offer update before calling all subscriptions
  • Loading branch information
AquiGorka authored Jun 26, 2024
1 parent 27b906f commit 0c2163d
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
1 change: 1 addition & 0 deletions pkg/jobcreator/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ func (controller *JobCreatorController) subscribeToSolver() error {
controller.log.Error("solver event", fmt.Errorf("RP received nil job offer"))
return
}
metricsDashboard.TrackJobOfferUpdate(*ev.JobOffer)
for _, sub := range controller.jobOfferSubscriptions {
go sub(*ev.JobOffer)
}
Expand Down
3 changes: 0 additions & 3 deletions pkg/jobcreator/onchain_jobcreator.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (

"github.com/davecgh/go-spew/spew"
"github.com/lilypad-tech/lilypad/pkg/data"
"github.com/lilypad-tech/lilypad/pkg/metricsDashboard"
"github.com/lilypad-tech/lilypad/pkg/system"
"github.com/lilypad-tech/lilypad/pkg/web3"
jobcreatorweb3 "github.com/lilypad-tech/lilypad/pkg/web3/bindings/jobcreator"
Expand Down Expand Up @@ -64,8 +63,6 @@ func (jobCreator *OnChainJobCreator) Start(ctx context.Context, cm *system.Clean
return errorChan
}

jobCreator.SubscribeToJobOfferUpdates(metricsDashboard.TrackJobOfferUpdate)

jobCreator.controller.SubscribeToJobOfferUpdates(func(evOffer data.JobOfferContainer) {
if evOffer.State != data.GetAgreementStateIndex("ResultsAccepted") {
return
Expand Down
3 changes: 2 additions & 1 deletion pkg/metricsDashboard/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ const nodeInfoEndpoint = "nodes"
const nodeConnectionEndpoint = "uptimes"
const dealsEndpoint = "deals"

var host = os.Getenv("API_HOST")

func trackEvent(path string, json string) {
var host = os.Getenv("API_HOST")
if host == "" {
return
}
Expand Down

0 comments on commit 0c2163d

Please sign in to comment.