Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-dms3-routing
Commits
c56a25e2
Commit
c56a25e2
authored
9 years ago
by
rht
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Run 'gofmt -s -w' on these files
parent
ca42d82f
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
21 additions
and
21 deletions
+21
-21
dht/dht_test.go
dht/dht_test.go
+3
-3
dht/providers.go
dht/providers.go
+1
-1
keyspace/xor_test.go
keyspace/xor_test.go
+15
-15
supernode/client.go
supernode/client.go
+1
-1
supernode/server.go
supernode/server.go
+1
-1
No files found.
dht/dht_test.go
View file @
c56a25e2
...
...
@@ -215,7 +215,7 @@ func TestProvides(t *testing.T) {
}
}
for
k
,
_
:=
range
testCaseValues
{
for
k
:=
range
testCaseValues
{
log
.
Debugf
(
"announcing provider for %s"
,
k
)
if
err
:=
dhts
[
3
]
.
Provide
(
ctx
,
k
);
err
!=
nil
{
t
.
Fatal
(
err
)
...
...
@@ -226,7 +226,7 @@ func TestProvides(t *testing.T) {
time
.
Sleep
(
time
.
Millisecond
*
6
)
n
:=
0
for
k
,
_
:=
range
testCaseValues
{
for
k
:=
range
testCaseValues
{
n
=
(
n
+
1
)
%
3
log
.
Debugf
(
"getting providers for %s from %d"
,
k
,
n
)
...
...
@@ -521,7 +521,7 @@ func TestProvidesMany(t *testing.T) {
}
}
for
k
,
_
:=
range
testCaseValues
{
for
k
:=
range
testCaseValues
{
// everyone should be able to find it...
for
_
,
dht
:=
range
dhts
{
log
.
Debugf
(
"getting providers for %s at %s"
,
k
,
dht
.
self
)
...
...
This diff is collapsed.
Click to expand it.
dht/providers.go
View file @
c56a25e2
...
...
@@ -77,7 +77,7 @@ func (pm *ProviderManager) run() {
case
lc
:=
<-
pm
.
getlocal
:
var
keys
[]
u
.
Key
for
k
,
_
:=
range
pm
.
local
{
for
k
:=
range
pm
.
local
{
keys
=
append
(
keys
,
k
)
}
lc
<-
keys
...
...
This diff is collapsed.
Click to expand it.
keyspace/xor_test.go
View file @
c56a25e2
...
...
@@ -10,9 +10,9 @@ import (
func
TestPrefixLen
(
t
*
testing
.
T
)
{
cases
:=
[][]
byte
{
[]
byte
{
0x00
,
0x00
,
0x00
,
0x80
,
0x00
,
0x00
,
0x00
},
[]
byte
{
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
},
[]
byte
{
0x00
,
0x58
,
0xFF
,
0x80
,
0x00
,
0x00
,
0xF0
},
{
0x00
,
0x00
,
0x00
,
0x80
,
0x00
,
0x00
,
0x00
},
{
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
},
{
0x00
,
0x58
,
0xFF
,
0x80
,
0x00
,
0x00
,
0xF0
},
}
lens
:=
[]
int
{
24
,
56
,
9
}
...
...
@@ -28,15 +28,15 @@ func TestPrefixLen(t *testing.T) {
func
TestXorKeySpace
(
t
*
testing
.
T
)
{
ids
:=
[][]
byte
{
[]
byte
{
0xFF
,
0xFF
,
0xFF
,
0xFF
},
[]
byte
{
0x00
,
0x00
,
0x00
,
0x00
},
[]
byte
{
0xFF
,
0xFF
,
0xFF
,
0xF0
},
{
0xFF
,
0xFF
,
0xFF
,
0xFF
},
{
0x00
,
0x00
,
0x00
,
0x00
},
{
0xFF
,
0xFF
,
0xFF
,
0xF0
},
}
ks
:=
[][
2
]
Key
{
[
2
]
Key
{
XORKeySpace
.
Key
(
ids
[
0
]),
XORKeySpace
.
Key
(
ids
[
0
])},
[
2
]
Key
{
XORKeySpace
.
Key
(
ids
[
1
]),
XORKeySpace
.
Key
(
ids
[
1
])},
[
2
]
Key
{
XORKeySpace
.
Key
(
ids
[
2
]),
XORKeySpace
.
Key
(
ids
[
2
])},
{
XORKeySpace
.
Key
(
ids
[
0
]),
XORKeySpace
.
Key
(
ids
[
0
])},
{
XORKeySpace
.
Key
(
ids
[
1
]),
XORKeySpace
.
Key
(
ids
[
1
])},
{
XORKeySpace
.
Key
(
ids
[
2
]),
XORKeySpace
.
Key
(
ids
[
2
])},
}
for
i
,
set
:=
range
ks
{
...
...
@@ -75,12 +75,12 @@ func TestXorKeySpace(t *testing.T) {
func
TestDistancesAndCenterSorting
(
t
*
testing
.
T
)
{
adjs
:=
[][]
byte
{
[]
byte
{
173
,
149
,
19
,
27
,
192
,
183
,
153
,
192
,
177
,
175
,
71
,
127
,
177
,
79
,
207
,
38
,
166
,
169
,
247
,
96
,
121
,
228
,
139
,
240
,
144
,
172
,
183
,
232
,
54
,
123
,
253
,
14
},
[]
byte
{
223
,
63
,
97
,
152
,
4
,
169
,
47
,
219
,
64
,
87
,
25
,
45
,
196
,
61
,
215
,
72
,
234
,
119
,
138
,
220
,
82
,
188
,
73
,
140
,
232
,
5
,
36
,
192
,
20
,
184
,
17
,
25
},
[]
byte
{
73
,
176
,
221
,
176
,
149
,
143
,
22
,
42
,
129
,
124
,
213
,
114
,
232
,
95
,
189
,
154
,
18
,
3
,
122
,
132
,
32
,
199
,
53
,
185
,
58
,
157
,
117
,
78
,
52
,
146
,
157
,
127
},
[]
byte
{
73
,
176
,
221
,
176
,
149
,
143
,
22
,
42
,
129
,
124
,
213
,
114
,
232
,
95
,
189
,
154
,
18
,
3
,
122
,
132
,
32
,
199
,
53
,
185
,
58
,
157
,
117
,
78
,
52
,
146
,
157
,
127
},
[]
byte
{
73
,
176
,
221
,
176
,
149
,
143
,
22
,
42
,
129
,
124
,
213
,
114
,
232
,
95
,
189
,
154
,
18
,
3
,
122
,
132
,
32
,
199
,
53
,
185
,
58
,
157
,
117
,
78
,
52
,
146
,
157
,
126
},
[]
byte
{
73
,
0
,
221
,
176
,
149
,
143
,
22
,
42
,
129
,
124
,
213
,
114
,
232
,
95
,
189
,
154
,
18
,
3
,
122
,
132
,
32
,
199
,
53
,
185
,
58
,
157
,
117
,
78
,
52
,
146
,
157
,
127
},
{
173
,
149
,
19
,
27
,
192
,
183
,
153
,
192
,
177
,
175
,
71
,
127
,
177
,
79
,
207
,
38
,
166
,
169
,
247
,
96
,
121
,
228
,
139
,
240
,
144
,
172
,
183
,
232
,
54
,
123
,
253
,
14
},
{
223
,
63
,
97
,
152
,
4
,
169
,
47
,
219
,
64
,
87
,
25
,
45
,
196
,
61
,
215
,
72
,
234
,
119
,
138
,
220
,
82
,
188
,
73
,
140
,
232
,
5
,
36
,
192
,
20
,
184
,
17
,
25
},
{
73
,
176
,
221
,
176
,
149
,
143
,
22
,
42
,
129
,
124
,
213
,
114
,
232
,
95
,
189
,
154
,
18
,
3
,
122
,
132
,
32
,
199
,
53
,
185
,
58
,
157
,
117
,
78
,
52
,
146
,
157
,
127
},
{
73
,
176
,
221
,
176
,
149
,
143
,
22
,
42
,
129
,
124
,
213
,
114
,
232
,
95
,
189
,
154
,
18
,
3
,
122
,
132
,
32
,
199
,
53
,
185
,
58
,
157
,
117
,
78
,
52
,
146
,
157
,
127
},
{
73
,
176
,
221
,
176
,
149
,
143
,
22
,
42
,
129
,
124
,
213
,
114
,
232
,
95
,
189
,
154
,
18
,
3
,
122
,
132
,
32
,
199
,
53
,
185
,
58
,
157
,
117
,
78
,
52
,
146
,
157
,
126
},
{
73
,
0
,
221
,
176
,
149
,
143
,
22
,
42
,
129
,
124
,
213
,
114
,
232
,
95
,
189
,
154
,
18
,
3
,
122
,
132
,
32
,
199
,
53
,
185
,
58
,
157
,
117
,
78
,
52
,
146
,
157
,
127
},
}
keys
:=
make
([]
Key
,
len
(
adjs
))
...
...
This diff is collapsed.
Click to expand it.
supernode/client.go
View file @
c56a25e2
...
...
@@ -86,7 +86,7 @@ func (c *Client) Provide(ctx context.Context, k u.Key) error {
msg
:=
pb
.
NewMessage
(
pb
.
Message_ADD_PROVIDER
,
string
(
k
),
0
)
// FIXME how is connectedness defined for the local node
pri
:=
[]
pb
.
PeerRoutingInfo
{
pb
.
PeerRoutingInfo
{
{
PeerInfo
:
peer
.
PeerInfo
{
ID
:
c
.
local
,
Addrs
:
c
.
peerhost
.
Addrs
(),
...
...
This diff is collapsed.
Click to expand it.
supernode/server.go
View file @
c56a25e2
...
...
@@ -73,7 +73,7 @@ func (s *Server) handleMessage(
case
dhtpb
.
Message_FIND_NODE
:
p
:=
s
.
peerstore
.
PeerInfo
(
peer
.
ID
(
req
.
GetKey
()))
pri
:=
[]
dhtpb
.
PeerRoutingInfo
{
dhtpb
.
PeerRoutingInfo
{
{
PeerInfo
:
p
,
// Connectedness: TODO
},
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment