Skip to content

Commit

Permalink
chore: rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
istae committed Aug 29, 2022
1 parent 4dcc46d commit 3d1b6fd
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 23 deletions.
2 changes: 1 addition & 1 deletion pkg/postage/batchstore/reserve.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ func (s *store) computeRadius() error {
if s.rs.Radius < s.rs.StorageRadius {
s.rs.StorageRadius = s.rs.Radius
if err := s.lowerBatchStorageRadius(); err != nil {
s.logger.Errorf("batchstore: lower batch storage radius: %v", err)
s.logger.Error(err, "batchstore: lower batch storage radius")
}
}

Expand Down
4 changes: 1 addition & 3 deletions pkg/postage/batchstore/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@ package batchstore_test

import (
"errors"
"io"
"math/rand"
"testing"

"github.com/ethersphere/bee/pkg/log"
"github.com/ethersphere/bee/pkg/logging"
"github.com/ethersphere/bee/pkg/postage"
"github.com/ethersphere/bee/pkg/postage/batchstore"
postagetest "github.com/ethersphere/bee/pkg/postage/testing"
Expand Down Expand Up @@ -195,7 +193,7 @@ func TestBatchStore_SetStorageRadius(t *testing.T) {

stateStore := mock.NewStateStore()
_ = stateStore.Put(batchstore.ReserveStateKey, &postage.ReserveState{Radius: radius})
batchStore, _ := batchstore.New(stateStore, nil, logging.New(io.Discard, 0))
batchStore, _ := batchstore.New(stateStore, nil, log.Noop)

_ = batchStore.SetStorageRadius(func(uint8) uint8 {
return oldStorageRadius
Expand Down
4 changes: 1 addition & 3 deletions pkg/puller/puller.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@ package puller
import (
"context"
"fmt"
"log"
"math"
"sync"
"time"

"github.com/aws/smithy-go/logging"
"github.com/ethersphere/bee/pkg/intervalstore"
"github.com/ethersphere/bee/pkg/log"
"github.com/ethersphere/bee/pkg/postage"
Expand Down Expand Up @@ -57,7 +55,7 @@ type Puller struct {
bins uint8 // how many bins do we support
}

func New(stateStore storage.StateStorer, topology topology.Driver, reserveState postage.ReserveStateGetter, pullSync pullsync.Interface, logger logging.Logger, o Options, warmupTime time.Duration) *Puller {
func New(stateStore storage.StateStorer, topology topology.Driver, reserveState postage.ReserveStateGetter, pullSync pullsync.Interface, logger log.Logger, o Options, warmupTime time.Duration) *Puller {
var (
bins uint8 = swarm.MaxBins
)
Expand Down
1 change: 0 additions & 1 deletion pkg/pullsync/pullsync.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ const (
rateWindowSize = 5 * time.Minute // rate tracker window size
)

const logMore = false // enable this for more logging
const MaxCursor = math.MaxUint64

var (
Expand Down
22 changes: 12 additions & 10 deletions pkg/topology/depthmonitor/depthmonitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ import (
"errors"
"time"

"github.com/ethersphere/bee/pkg/logging"
"github.com/ethersphere/bee/pkg/log"
"github.com/ethersphere/bee/pkg/postage"
topologyDriver "github.com/ethersphere/bee/pkg/topology"
)

const loggerName = "depthmonitor"

var (
manageWait = 5 * time.Minute
minimumRadius uint8 = 4
Expand Down Expand Up @@ -47,7 +49,7 @@ type Service struct {
topology Topology
syncer SyncReporter
reserve ReserveReporter
logger logging.Logger
logger log.Logger
bs postage.Storer
quit chan struct{} // to request service to stop
stopped chan struct{} // to signal stopping of bg worker
Expand All @@ -59,7 +61,7 @@ func New(
syncer SyncReporter,
reserve ReserveReporter,
bs postage.Storer,
logger logging.Logger,
logger log.Logger,
warmupTime time.Duration,
) *Service {

Expand All @@ -68,7 +70,7 @@ func New(
syncer: syncer,
reserve: reserve,
bs: bs,
logger: logger,
logger: logger.WithName(loggerName).Register(),
quit: make(chan struct{}),
stopped: make(chan struct{}),
}
Expand All @@ -90,11 +92,11 @@ func (s *Service) manage(warmupTime time.Duration) {
if radius == 0 {
radius = reserveRadius
}
s.logger.Infof("depthmonitor: warmup period complete, starting worker with initial depth %d", radius)
s.logger.Info("depthmonitor: warmup period complete, starting worker", "initial depth", radius)
return radius
})
if err != nil {
s.logger.Errorf("depthmonitor: batchstore set storage radius: %v", err)
s.logger.Error(err, "depthmonitor: batchstore set storage radius")
}

// wait for warmup
Expand All @@ -115,12 +117,12 @@ func (s *Service) manage(warmupTime time.Duration) {

currentSize, err := s.reserve.ReserveSize()
if err != nil {
s.logger.Errorf("depthmonitor: failed reading reserve size %v", err)
s.logger.Error(err, "depthmonitor: failed reading reserve size")
continue
}

rate := s.syncer.Rate()
s.logger.Tracef("depthmonitor: current size %d, %.1f chunks/sec rate", currentSize, rate)
s.logger.Debug("depthmonitor size and rate", "current size", currentSize, "chunks/sec rate", rate)

// we have crossed 50% utilization
if currentSize > halfCapacity {
Expand All @@ -132,12 +134,12 @@ func (s *Service) manage(warmupTime time.Duration) {
err = s.bs.SetStorageRadius(func(radius uint8) uint8 {
if radius > minimumRadius {
radius--
s.logger.Infof("depthmonitor: reducing storage depth to %d", radius)
s.logger.Info("depthmonitor: reducing storage depth", "depth", radius)
}
return radius
})
if err != nil {
s.logger.Errorf("depthmonitor: batchstore set storage radius: %v", err)
s.logger.Error(err, "depthmonitor: batchstore set storage radius")
}
}
}
Expand Down
5 changes: 2 additions & 3 deletions pkg/topology/depthmonitor/depthmonitor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@
package depthmonitor_test

import (
"io"
"sync"
"testing"
"time"

"github.com/ethersphere/bee/pkg/logging"
"github.com/ethersphere/bee/pkg/log"
"github.com/ethersphere/bee/pkg/postage"
mockbatchstore "github.com/ethersphere/bee/pkg/postage/batchstore/mock"
"github.com/ethersphere/bee/pkg/storage"
Expand Down Expand Up @@ -48,7 +47,7 @@ func newTestSvc(
batchStore = bs
}

return depthmonitor.New(topo, syncer, reserve, batchStore, logging.New(io.Discard, 5), warmupTime)
return depthmonitor.New(topo, syncer, reserve, batchStore, log.Noop, warmupTime)
}

func TestDepthMonitorService(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions pkg/topology/kademlia/kademlia.go
Original file line number Diff line number Diff line change
Expand Up @@ -1369,7 +1369,7 @@ func (k *Kad) UpdateReachability(status p2p.ReachabilityStatus) {
if status == p2p.ReachabilityStatusUnknown {
return
}
k.logger.Info("reachability updated", "reachability", status)
k.logger.Debug("reachability updated", "reachability", status)
k.reachability = status
k.metrics.ReachabilityStatus.WithLabelValues(status.String()).Set(0)
}
Expand Down Expand Up @@ -1447,7 +1447,7 @@ func (k *Kad) SetStorageRadius(d uint8) {

k.storageRadius = d
k.metrics.CurrentStorageDepth.Set(float64(k.storageRadius))
k.logger.Tracef("kademlia: set storage radius %d", k.storageRadius)
k.logger.Debug("kademlia set storage radius", "radius", k.storageRadius)

oldDepth := k.depth
k.recalcDepth()
Expand Down

0 comments on commit 3d1b6fd

Please sign in to comment.