Skip to content

Commit

Permalink
Stat LastRun and NextRun only if kubo is running with the Accelerated…
Browse files Browse the repository at this point in the history
… DHT
  • Loading branch information
gsergey418alt committed Jan 30, 2025
1 parent 540ba54 commit 5bc192e
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion provider/reprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ type reprovider struct {
noReprovideInFlight chan struct{}

maxReprovideBatchSize uint
acceleratedDHTClient bool

statLk sync.Mutex
totalProvides, lastReprovideBatchSize uint64
Expand Down Expand Up @@ -161,6 +162,13 @@ func Allowlist(allowlist verifcid.Allowlist) Option {
}
}

func AcceleratedDHTClient(v bool) Option {
return func(system *reprovider) error {
system.acceleratedDHTClient = v
return nil
}

Check warning on line 169 in provider/reprovider.go

View check run for this annotation

Codecov / codecov/patch

provider/reprovider.go#L165-L169

Added lines #L165 - L169 were not covered by tests
}

func ReproviderInterval(duration time.Duration) Option {
return func(system *reprovider) error {
system.reprovideInterval = duration
Expand Down Expand Up @@ -358,7 +366,9 @@ func (s *reprovider) run() {
s.statLk.Lock()
s.avgProvideDuration = (totalProvideTime + dur) / (time.Duration(s.totalProvides) + time.Duration(len(keys)))
s.totalProvides += uint64(len(keys))
s.lastRun = time.Now()
if s.acceleratedDHTClient {
s.lastRun = time.Now()
}

Check warning on line 371 in provider/reprovider.go

View check run for this annotation

Codecov / codecov/patch

provider/reprovider.go#L370-L371

Added lines #L370 - L371 were not covered by tests

log.Debugf("finished providing of %d keys. It took %v with an average of %v per provide", len(keys), dur, recentAvgProvideDuration)

Expand Down

0 comments on commit 5bc192e

Please sign in to comment.