Skip to content

Commit

Permalink
logs cleanup (#63)
Browse files Browse the repository at this point in the history
  • Loading branch information
tarassh authored Jan 17, 2025
1 parent 6261542 commit 1f62781
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
1 change: 0 additions & 1 deletion cmd/light-client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion internal/light-client/poller/challenge.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 5 additions & 1 deletion internal/light-client/poller/poll.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)

Expand Down
5 changes: 5 additions & 0 deletions internal/light-client/schemapb/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,8 @@ func (w *Workload) ReadableString() string {
w.Challenge,
)
}

func (w *Workload) GetCID() *cid.Cid {
c, _ := cid.Cast(w.IpfsCid)
return &c
}

0 comments on commit 1f62781

Please sign in to comment.