fix: code review

This commit is contained in:
Richard Ramos 2024-10-14 12:14:37 -04:00
parent f29ce5fef0
commit f40a23ccd3
No known key found for this signature in database
GPG Key ID: 1CE87DB518195760
3 changed files with 13 additions and 3 deletions

View File

@ -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"
@ -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
}
@ -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..

View File

@ -141,6 +141,13 @@ loop:
continue
}
select {
case <-ctx.Done():
return ctx.Err()
default:
// continue...
}
logger.Debug("processBatch - received work")
semaphore <- struct{}{}

View File

@ -225,7 +225,7 @@ func TestStoreClient(t *testing.T) {
// Handle temporal history query with a zero-size time window
response, err = wakuStore.Query(ctx, FilterCriteria{ContentFilter: protocol.NewContentFilter(pubsubTopic, "test"), TimeStart: startTime, TimeEnd: startTime})
require.NoError(t, err)
require.Len(t, response.messages, 0)
require.Len(t, response.Messages(), 0)
require.Empty(t, response.Cursor())
// Should not include data