Skip to content

Commit

Permalink
fix: typos
Browse files Browse the repository at this point in the history
  • Loading branch information
martinconic committed Nov 5, 2024
1 parent ec73f0c commit 72de4df
Show file tree
Hide file tree
Showing 15 changed files with 84 additions and 84 deletions.
2 changes: 1 addition & 1 deletion openapi/SwarmCommon.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -928,7 +928,7 @@ components:
type: boolean
lastSyncedBlock:
type: integer
commitedDepth:
committedDepth:
type: integer

StatusResponse:
Expand Down
6 changes: 3 additions & 3 deletions pkg/api/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type statusSnapshotResponse struct {
BatchCommitment uint64 `json:"batchCommitment"`
IsReachable bool `json:"isReachable"`
LastSyncedBlock uint64 `json:"lastSyncedBlock"`
CommitedDepth uint8 `json:"commitedDepth"`
CommittedDepth uint8 `json:"committedDepth"`
}

type statusResponse struct {
Expand Down Expand Up @@ -95,7 +95,7 @@ func (s *Service) statusGetHandler(w http.ResponseWriter, _ *http.Request) {
BatchCommitment: ss.BatchCommitment,
IsReachable: ss.IsReachable,
LastSyncedBlock: ss.LastSyncedBlock,
CommitedDepth: uint8(ss.CommitedDepth),
CommittedDepth: uint8(ss.CommittedDepth),
})
}

Expand Down Expand Up @@ -143,7 +143,7 @@ func (s *Service) statusGetPeersHandler(w http.ResponseWriter, r *http.Request)
snapshot.BatchCommitment = ss.BatchCommitment
snapshot.IsReachable = ss.IsReachable
snapshot.LastSyncedBlock = ss.LastSyncedBlock
snapshot.CommitedDepth = uint8(ss.CommitedDepth)
snapshot.CommittedDepth = uint8(ss.CommittedDepth)
}

mu.Lock()
Expand Down
8 changes: 4 additions & 4 deletions pkg/api/status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func TestGetStatus(t *testing.T) {
BatchCommitment: 1,
IsReachable: true,
LastSyncedBlock: 6092500,
CommitedDepth: 1,
CommittedDepth: 1,
}

ssMock := &statusSnapshotMock{
Expand All @@ -50,7 +50,7 @@ func TestGetStatus(t *testing.T) {
storageRadius: ssr.StorageRadius,
commitment: ssr.BatchCommitment,
chainState: &postage.ChainState{Block: ssr.LastSyncedBlock},
commitedDepth: ssr.CommitedDepth,
committedDepth: ssr.CommittedDepth,
}

statusSvc := status.NewService(
Expand Down Expand Up @@ -124,7 +124,7 @@ type statusSnapshotMock struct {
commitment uint64
chainState *postage.ChainState
neighborhoods []*storer.NeighborhoodStat
commitedDepth uint8
committedDepth uint8
}

func (m *statusSnapshotMock) SyncRate() float64 { return m.syncRate }
Expand All @@ -138,4 +138,4 @@ func (m *statusSnapshotMock) ReserveSizeWithinRadius() uint64 {
func (m *statusSnapshotMock) NeighborhoodsStat(ctx context.Context) ([]*storer.NeighborhoodStat, error) {
return m.neighborhoods, nil
}
func (m *statusSnapshotMock) CommitedDepth() uint8 { return m.commitedDepth }
func (m *statusSnapshotMock) CommittedDepth() uint8 { return m.committedDepth }
18 changes: 9 additions & 9 deletions pkg/salud/salud.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ func (s *service) salud(mode string, minPeersPerbin int, durPercentile float64,
return
}

networkRadius, nHoodRadius := s.commitedDepth(peers)
networkRadius, nHoodRadius := s.committedDepth(peers)
avgDur := totaldur / float64(len(peers))
pDur := percentileDur(peers, durPercentile)
pConns := percentileConns(peers, connsPercentile)
Expand All @@ -195,8 +195,8 @@ func (s *service) salud(mode string, minPeersPerbin int, durPercentile float64,
continue
}

if networkRadius > 0 && peer.status.CommitedDepth < uint32(networkRadius-2) {
s.logger.Debug("radius health failure", "radius", peer.status.CommitedDepth, "peer_address", peer.addr)
if networkRadius > 0 && peer.status.CommittedDepth < uint32(networkRadius-2) {
s.logger.Debug("radius health failure", "radius", peer.status.CommittedDepth, "peer_address", peer.addr)
} else if peer.dur.Seconds() > pDur {
s.logger.Debug("response duration below threshold", "duration", peer.dur, "peer_address", peer.addr)
} else if peer.status.ConnectedPeers < pConns {
Expand All @@ -217,9 +217,9 @@ func (s *service) salud(mode string, minPeersPerbin int, durPercentile float64,
}

selfHealth := true
if nHoodRadius == networkRadius && s.reserve.CommitedDepth() != networkRadius {
if nHoodRadius == networkRadius && s.reserve.CommittedDepth() != networkRadius {
selfHealth = false
s.logger.Warning("node is unhealthy due to storage radius discrepancy", "self_radius", s.reserve.CommitedDepth(), "network_radius", networkRadius)
s.logger.Warning("node is unhealthy due to storage radius discrepancy", "self_radius", s.reserve.CommittedDepth(), "network_radius", networkRadius)
}

s.isSelfHealthy.Store(selfHealth)
Expand Down Expand Up @@ -288,17 +288,17 @@ func percentileConns(peers []peer, p float64) uint64 {
}

// radius finds the most common radius.
func (s *service) commitedDepth(peers []peer) (uint8, uint8) {
func (s *service) committedDepth(peers []peer) (uint8, uint8) {

var networkDepth [swarm.MaxBins]int
var nHoodDepth [swarm.MaxBins]int

for _, peer := range peers {
if peer.status.CommitedDepth < uint32(swarm.MaxBins) {
if peer.status.CommittedDepth < uint32(swarm.MaxBins) {
if peer.neighbor {
nHoodDepth[peer.status.CommitedDepth]++
nHoodDepth[peer.status.CommittedDepth]++
}
networkDepth[peer.status.CommitedDepth]++
networkDepth[peer.status.CommittedDepth]++
}
}

Expand Down
28 changes: 14 additions & 14 deletions pkg/salud/salud_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,28 +31,28 @@ func TestSalud(t *testing.T) {
t.Parallel()
peers := []peer{
// fully healhy
{swarm.RandAddress(t), &status.Snapshot{ConnectedPeers: 100, StorageRadius: 8, BeeMode: "full", BatchCommitment: 50, ReserveSize: 100, CommitedDepth: 8}, 1, true},
{swarm.RandAddress(t), &status.Snapshot{ConnectedPeers: 100, StorageRadius: 8, BeeMode: "full", BatchCommitment: 50, ReserveSize: 100, CommitedDepth: 8}, 1, true},
{swarm.RandAddress(t), &status.Snapshot{ConnectedPeers: 100, StorageRadius: 8, BeeMode: "full", BatchCommitment: 50, ReserveSize: 100, CommitedDepth: 8}, 1, true},
{swarm.RandAddress(t), &status.Snapshot{ConnectedPeers: 100, StorageRadius: 8, BeeMode: "full", BatchCommitment: 50, ReserveSize: 100, CommitedDepth: 8}, 1, true},
{swarm.RandAddress(t), &status.Snapshot{ConnectedPeers: 100, StorageRadius: 8, BeeMode: "full", BatchCommitment: 50, ReserveSize: 100, CommitedDepth: 8}, 1, true},
{swarm.RandAddress(t), &status.Snapshot{ConnectedPeers: 100, StorageRadius: 8, BeeMode: "full", BatchCommitment: 50, ReserveSize: 100, CommitedDepth: 8}, 1, true},
{swarm.RandAddress(t), &status.Snapshot{ConnectedPeers: 100, StorageRadius: 8, BeeMode: "full", BatchCommitment: 50, ReserveSize: 100, CommittedDepth: 8}, 1, true},
{swarm.RandAddress(t), &status.Snapshot{ConnectedPeers: 100, StorageRadius: 8, BeeMode: "full", BatchCommitment: 50, ReserveSize: 100, CommittedDepth: 8}, 1, true},
{swarm.RandAddress(t), &status.Snapshot{ConnectedPeers: 100, StorageRadius: 8, BeeMode: "full", BatchCommitment: 50, ReserveSize: 100, CommittedDepth: 8}, 1, true},
{swarm.RandAddress(t), &status.Snapshot{ConnectedPeers: 100, StorageRadius: 8, BeeMode: "full", BatchCommitment: 50, ReserveSize: 100, CommittedDepth: 8}, 1, true},
{swarm.RandAddress(t), &status.Snapshot{ConnectedPeers: 100, StorageRadius: 8, BeeMode: "full", BatchCommitment: 50, ReserveSize: 100, CommittedDepth: 8}, 1, true},
{swarm.RandAddress(t), &status.Snapshot{ConnectedPeers: 100, StorageRadius: 8, BeeMode: "full", BatchCommitment: 50, ReserveSize: 100, CommittedDepth: 8}, 1, true},

// healthy since radius >= most common radius - 2
{swarm.RandAddress(t), &status.Snapshot{ConnectedPeers: 100, StorageRadius: 7, BeeMode: "full", BatchCommitment: 50, ReserveSize: 100, CommitedDepth: 7}, 1, true},
{swarm.RandAddress(t), &status.Snapshot{ConnectedPeers: 100, StorageRadius: 7, BeeMode: "full", BatchCommitment: 50, ReserveSize: 100, CommittedDepth: 7}, 1, true},

// radius too low
{swarm.RandAddress(t), &status.Snapshot{ConnectedPeers: 100, StorageRadius: 5, BeeMode: "full", BatchCommitment: 50, ReserveSize: 100, CommitedDepth: 5}, 1, false},
{swarm.RandAddress(t), &status.Snapshot{ConnectedPeers: 100, StorageRadius: 5, BeeMode: "full", BatchCommitment: 50, ReserveSize: 100, CommittedDepth: 5}, 1, false},

// dur too long
{swarm.RandAddress(t), &status.Snapshot{ConnectedPeers: 100, StorageRadius: 8, BeeMode: "full", BatchCommitment: 50, ReserveSize: 100, CommitedDepth: 8}, 2, false},
{swarm.RandAddress(t), &status.Snapshot{ConnectedPeers: 100, StorageRadius: 8, BeeMode: "full", BatchCommitment: 50, ReserveSize: 100, CommitedDepth: 8}, 2, false},
{swarm.RandAddress(t), &status.Snapshot{ConnectedPeers: 100, StorageRadius: 8, BeeMode: "full", BatchCommitment: 50, ReserveSize: 100, CommittedDepth: 8}, 2, false},
{swarm.RandAddress(t), &status.Snapshot{ConnectedPeers: 100, StorageRadius: 8, BeeMode: "full", BatchCommitment: 50, ReserveSize: 100, CommittedDepth: 8}, 2, false},

// connections not enough
{swarm.RandAddress(t), &status.Snapshot{ConnectedPeers: 90, StorageRadius: 8, BeeMode: "full", BatchCommitment: 50, ReserveSize: 100, CommitedDepth: 8}, 1, false},
{swarm.RandAddress(t), &status.Snapshot{ConnectedPeers: 90, StorageRadius: 8, BeeMode: "full", BatchCommitment: 50, ReserveSize: 100, CommittedDepth: 8}, 1, false},

// commitment wrong
{swarm.RandAddress(t), &status.Snapshot{ConnectedPeers: 100, StorageRadius: 8, BeeMode: "full", BatchCommitment: 35, ReserveSize: 100, CommitedDepth: 8}, 1, false},
{swarm.RandAddress(t), &status.Snapshot{ConnectedPeers: 100, StorageRadius: 8, BeeMode: "full", BatchCommitment: 35, ReserveSize: 100, CommittedDepth: 8}, 1, false},
}

statusM := &statusMock{make(map[string]peer)}
Expand Down Expand Up @@ -137,8 +137,8 @@ func TestSelfHealthyCapacityDoubling(t *testing.T) {
t.Parallel()
peers := []peer{
// fully healhy
{swarm.RandAddress(t), &status.Snapshot{ConnectedPeers: 100, StorageRadius: 8, BeeMode: "full", CommitedDepth: 8}, 0, true},
{swarm.RandAddress(t), &status.Snapshot{ConnectedPeers: 100, StorageRadius: 8, BeeMode: "full", CommitedDepth: 8}, 0, true},
{swarm.RandAddress(t), &status.Snapshot{ConnectedPeers: 100, StorageRadius: 8, BeeMode: "full", CommittedDepth: 8}, 0, true},
{swarm.RandAddress(t), &status.Snapshot{ConnectedPeers: 100, StorageRadius: 8, BeeMode: "full", CommittedDepth: 8}, 0, true},
}

statusM := &statusMock{make(map[string]peer)}
Expand Down
54 changes: 27 additions & 27 deletions pkg/status/internal/pb/status.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/status/internal/pb/status.proto
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ message Snapshot {
bool IsReachable = 8;
uint64 ReserveSizeWithinRadius = 9;
uint64 LastSyncedBlock = 10;
uint32 CommitedDepth = 11;
uint32 CommittedDepth = 11;
}
8 changes: 4 additions & 4 deletions pkg/status/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ type Reserve interface {
ReserveSize() int
ReserveSizeWithinRadius() uint64
StorageRadius() uint8
CommitedDepth() uint8
CommittedDepth() uint8
}

type topologyDriver interface {
Expand Down Expand Up @@ -87,14 +87,14 @@ func (s *Service) LocalSnapshot() (*Snapshot, error) {
reserveSizeWithinRadius uint64
connectedPeers uint64
neighborhoodSize uint64
commitedDepth uint8
committedDepth uint8
)

if s.reserve != nil {
storageRadius = s.reserve.StorageRadius()
reserveSize = uint64(s.reserve.ReserveSize())
reserveSizeWithinRadius = s.reserve.ReserveSizeWithinRadius()
commitedDepth = s.reserve.CommitedDepth()
committedDepth = s.reserve.CommittedDepth()
}

if s.sync != nil {
Expand Down Expand Up @@ -131,7 +131,7 @@ func (s *Service) LocalSnapshot() (*Snapshot, error) {
BatchCommitment: commitment,
IsReachable: s.topologyDriver.IsReachable(),
LastSyncedBlock: s.chainState.GetChainState().Block,
CommitedDepth: uint32(commitedDepth),
CommittedDepth: uint32(committedDepth),
}, nil
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/status/status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func TestStatus(t *testing.T) {
NeighborhoodSize: 1,
IsReachable: true,
LastSyncedBlock: 6092500,
CommitedDepth: 1,
CommittedDepth: 1,
}

sssMock := &statusSnapshotMock{want}
Expand Down Expand Up @@ -204,4 +204,4 @@ func (m *statusSnapshotMock) GetChainState() *postage.ChainState {
func (m *statusSnapshotMock) ReserveSizeWithinRadius() uint64 {
return m.Snapshot.ReserveSizeWithinRadius
}
func (m *statusSnapshotMock) CommitedDepth() uint8 { return uint8(m.Snapshot.CommitedDepth) }
func (m *statusSnapshotMock) CommittedDepth() uint8 { return uint8(m.Snapshot.CommittedDepth) }
Loading

0 comments on commit 72de4df

Please sign in to comment.