Skip to content

Commit

Permalink
fix: code review
Browse files Browse the repository at this point in the history
  • Loading branch information
richard-ramos committed Oct 14, 2024
1 parent f29ce5f commit 397b4b5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 5 additions & 2 deletions waku/v2/api/history/cycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const defaultBackoff = 10 * time.Second
const graylistBackoff = 3 * time.Minute
const storenodeVerificationInterval = time.Second
const storenodeMaxFailedRequests uint = 2
const minStorenodesToChooseFrom = 3
const isAndroidEmulator = runtime.GOOS == "android" && runtime.GOARCH == "amd64"
const findNearestMailServer = !isAndroidEmulator
const overrideDNS = runtime.GOOS == "android" || runtime.GOOS == "ios"
Expand Down Expand Up @@ -151,7 +152,7 @@ func (m *StorenodeCycle) disconnectActiveStorenode(backoffDuration time.Duration

func (m *StorenodeCycle) Cycle(ctx context.Context) {
if m.storenodeConfigProvider == nil {
m.logger.Info("storenodeConfigProvider not yet setup")
m.logger.Debug("storenodeConfigProvider not yet setup")
return
}

Expand Down Expand Up @@ -285,8 +286,10 @@ func (m *StorenodeCycle) findNewStorenode(ctx context.Context) error {

// Picks a random storenode amongs the ones with the lowest latency
// The pool size is 1/4 of the storenodes were pinged successfully
// If the pool size is less than `minStorenodesToChooseFrom`, it will
// pick a storenode fromm all the available storenodes
pSize := poolSize(len(allStorenodes) - 1)
if pSize <= 0 {
if pSize <= minStorenodesToChooseFrom {
pSize = len(allStorenodes)
if pSize <= 0 {
m.logger.Warn("No storenodes available") // Do nothing..
Expand Down
7 changes: 7 additions & 0 deletions waku/v2/api/history/history.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,13 @@ loop:
continue
}

select {
case <-ctx.Done():
return ctx.Err()
default:
// continue...
}

logger.Debug("processBatch - received work")

semaphore <- struct{}{}
Expand Down

0 comments on commit 397b4b5

Please sign in to comment.