Skip to content

Commit

Permalink
Add clientless oracle process
Browse files Browse the repository at this point in the history
  • Loading branch information
rbajollari committed Feb 19, 2024
1 parent df141dc commit e965d14
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions oracle/oracle.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,36 @@ func (o *Oracle) Start(ctx context.Context) error {
}
}

// Starts oracle process without a client for running on an Ojo node without submitting
// prevotes and votes.
func (o *Oracle) StartClientless(ctx context.Context, params oracletypes.Params) error {
o.paramCache.UpdateParamCache(0, params, nil)

for {
select {
case <-ctx.Done():
o.closer.Close()

default:
o.logger.Debug().Msg("starting clientless oracle tick")

startTime := time.Now()

if err := o.tick(ctx); err != nil {
telemetry.IncrCounter(1, "failure", "clientless tick")
o.logger.Err(err).Msg("clientless oracle tick failed")
}

o.lastPriceSyncTS = time.Now()

telemetry.MeasureSince(startTime, "runtime", "clientless tick")
telemetry.IncrCounter(1, "new", "clientless tick")

time.Sleep(tickerSleep)
}
}
}

// Stop stops the oracle process and waits for it to gracefully exit.
func (o *Oracle) Stop() {
o.closer.Close()
Expand Down Expand Up @@ -688,6 +718,16 @@ func (o *Oracle) tick(ctx context.Context) error {
return nil
}

func (o *Oracle) tickClientless(ctx context.Context) error {

Check failure on line 721 in oracle/oracle.go

View workflow job for this annotation

GitHub Actions / Run golangci-lint

func `(*Oracle).tickClientless` is unused (unused)
o.logger.Debug().Msg("executing clientless oracle tick")

if err := o.SetPrices(ctx); err != nil {

Check failure on line 724 in oracle/oracle.go

View workflow job for this annotation

GitHub Actions / Run golangci-lint

redundant if ...; err != nil check, just return error instead.

Check failure on line 724 in oracle/oracle.go

View workflow job for this annotation

GitHub Actions / Run golangci-lint

if-return: redundant if ...; err != nil check, just return error instead. (revive)
return err
}

return nil
}

// GenerateSalt generates a random salt, size length/2, as a HEX encoded string.
func GenerateSalt(length int) (string, error) {
if length == 0 {
Expand Down

0 comments on commit e965d14

Please sign in to comment.