From 1f6278165a905b8d01f702c52bb5eec66ce0d5c3 Mon Sep 17 00:00:00 2001 From: tarassh Date: Fri, 17 Jan 2025 12:14:33 -0800 Subject: [PATCH] logs cleanup (#63) --- cmd/light-client/main.go | 1 - internal/light-client/poller/challenge.go | 2 +- internal/light-client/poller/poll.go | 6 +++++- internal/light-client/schemapb/utils.go | 5 +++++ 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/cmd/light-client/main.go b/cmd/light-client/main.go index 945cf2a..c620081 100644 --- a/cmd/light-client/main.go +++ b/cmd/light-client/main.go @@ -41,7 +41,6 @@ var rootCmd = &cobra.Command{ Version: fmt.Sprintf("%s, commit %s", common.Version, common.GitCommit), PersistentPreRun: func(cmd *cobra.Command, args []string) { logging.SetLogLevel("*", loglevel) - logging.SetLogLevel("rpc", "error") // Load the configuration config := das.LoadConfig() diff --git a/internal/light-client/poller/challenge.go b/internal/light-client/poller/challenge.go index 648465c..d6c8f72 100644 --- a/internal/light-client/poller/challenge.go +++ b/internal/light-client/poller/challenge.go @@ -138,7 +138,7 @@ func (c *Challenge) Solve(workload *pb.Workload, identity *utils.Identity) (bool // Compare the target switch c.ClauseType.Type { case "Modulo": - log.Infof("Solving Modulo challenge M=%s, K=%s", c.ClauseType.M, c.ClauseType.K) + log.Debugf("Modulo challenge M=%s, K=%s ...", c.ClauseType.M, c.ClauseType.K) eligible, err := c.solveModulo(target, c.ClauseType.M, c.ClauseType.K) if err != nil { return false, nil, fmt.Errorf("failed to solve Modulo challenge: %w", err) diff --git a/internal/light-client/poller/poll.go b/internal/light-client/poller/poll.go index 783ae2d..6801a9b 100644 --- a/internal/light-client/poller/poll.go +++ b/internal/light-client/poller/poll.go @@ -48,6 +48,7 @@ func (p *WorkloadPoller) periodicPoll() { } // Process the workloads + for _, workload := range response.Workloads { log.Debugf("processing workload: %v", workload.GetWorkload().ReadableString()) challenge, err := Decode(workload.Workload.Challenge) @@ -60,12 +61,15 @@ func (p *WorkloadPoller) periodicPoll() { log.Errorf("failed to solve challenge: %s", err) } - log.Infof("workload is eligible: %v", eligible) + log.Debugf("workload is eligible: %v", eligible) if eligible { + log.Infof("workload for CID %s is eligible", workload.GetWorkload().GetCID().String()) p.sampler.ProcessEvent(workload, seed) } } + log.Infof("%d workloads available", len(response.Workloads)) + // unix timestamp to time nextUpdate := time.Unix(int64(response.NextUpdateTimestamp), 0) diff --git a/internal/light-client/schemapb/utils.go b/internal/light-client/schemapb/utils.go index e159984..bbdf0bd 100644 --- a/internal/light-client/schemapb/utils.go +++ b/internal/light-client/schemapb/utils.go @@ -22,3 +22,8 @@ func (w *Workload) ReadableString() string { w.Challenge, ) } + +func (w *Workload) GetCID() *cid.Cid { + c, _ := cid.Cast(w.IpfsCid) + return &c +}