Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

swarm: change MaxPO #1593

Merged
merged 3 commits into from
Apr 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions pkg/kademlia/kademlia.go
Original file line number Diff line number Diff line change
Expand Up @@ -1069,6 +1069,22 @@ func (k *Kad) Snapshot() *topology.KadParams {
Bin13: infos[13],
Bin14: infos[14],
Bin15: infos[15],
Bin16: infos[16],
Bin17: infos[17],
Bin18: infos[18],
Bin19: infos[19],
Bin20: infos[20],
Bin21: infos[21],
Bin22: infos[22],
Bin23: infos[23],
Bin24: infos[24],
Bin25: infos[25],
Bin26: infos[26],
Bin27: infos[27],
Bin28: infos[28],
Bin29: infos[29],
Bin30: infos[30],
Bin31: infos[31],
},
}
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/kademlia/kademlia_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,16 +156,16 @@ func TestNeighborhoodDepth(t *testing.T) {

// add a whole bunch of peers in bin 15, expect depth to stay at 15
for i := 0; i < 15; i++ {
addr = test.RandomAddressAt(base, 15)
addr = test.RandomAddressAt(base, int(swarm.MaxPO))
addOne(t, signer, kad, ab, addr)
}

waitCounter(t, &conns, 15)
kDepth(t, kad, 15)
kDepth(t, kad, 31)

// remove one at 14, depth should be 14
removeOne(kad, addrs[len(addrs)-5])
kDepth(t, kad, 14)
kDepth(t, kad, 30)

// empty bin 9 and expect depth 9
for i := 0; i < 4; i++ {
Expand Down
4 changes: 2 additions & 2 deletions pkg/pullsync/pullstorage/pullstorage.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ LOOP:

// Cursors gets the last BinID for every bin in the local storage
func (s *ps) Cursors(ctx context.Context) (curs []uint64, err error) {
curs = make([]uint64, 16)
for i := uint8(0); i < 16; i++ {
curs = make([]uint64, swarm.MaxBins)
for i := uint8(0); i < swarm.MaxBins; i++ {
binID, err := s.Storer.LastPullSubscriptionBinID(i)
if err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion pkg/swarm/swarm.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const (
BmtBranches = 128
ChunkSize = SectionSize * Branches
HashSize = 32
MaxPO uint8 = 15
MaxPO uint8 = 31
ExtendedPO uint8 = MaxPO + 5
MaxBins = MaxPO + 1
ChunkWithSpanSize = ChunkSize + SpanSize
Expand Down
16 changes: 16 additions & 0 deletions pkg/topology/topology.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,22 @@ type KadBins struct {
Bin13 BinInfo `json:"bin_13"`
Bin14 BinInfo `json:"bin_14"`
Bin15 BinInfo `json:"bin_15"`
Bin16 BinInfo `json:"bin_16"`
Bin17 BinInfo `json:"bin_17"`
Bin18 BinInfo `json:"bin_18"`
Bin19 BinInfo `json:"bin_19"`
Bin20 BinInfo `json:"bin_20"`
Bin21 BinInfo `json:"bin_21"`
Bin22 BinInfo `json:"bin_22"`
Bin23 BinInfo `json:"bin_23"`
Bin24 BinInfo `json:"bin_24"`
Bin25 BinInfo `json:"bin_25"`
Bin26 BinInfo `json:"bin_26"`
Bin27 BinInfo `json:"bin_27"`
Bin28 BinInfo `json:"bin_28"`
Bin29 BinInfo `json:"bin_29"`
Bin30 BinInfo `json:"bin_30"`
Bin31 BinInfo `json:"bin_31"`
}

type KadParams struct {
Expand Down