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
Commits
57e088bb
Commit
57e088bb
authored
Sep 19, 2014
by
Brian Tiger Chow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(bitswap:testnet) use peer.Map
parent
a8a7caa0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
8 deletions
+8
-8
exchange/bitswap/testnet/routing.go
exchange/bitswap/testnet/routing.go
+8
-8
No files found.
exchange/bitswap/testnet/routing.go
View file @
57e088bb
...
...
@@ -24,13 +24,13 @@ type RoutingServer interface {
func
VirtualRoutingServer
()
RoutingServer
{
return
&
hashTable
{
m
:
make
(
map
[
u
.
Key
]
map
[
*
peer
.
Peer
]
bool
),
providers
:
make
(
map
[
u
.
Key
]
peer
.
Map
),
}
}
type
hashTable
struct
{
lock
sync
.
RWMutex
m
map
[
u
.
Key
]
map
[
*
peer
.
Peer
]
bool
lock
sync
.
RWMutex
providers
map
[
u
.
Key
]
peer
.
Map
}
var
TODO
=
errors
.
New
(
"TODO"
)
...
...
@@ -39,11 +39,11 @@ func (rs *hashTable) Announce(p *peer.Peer, k u.Key) error {
rs
.
lock
.
Lock
()
defer
rs
.
lock
.
Unlock
()
_
,
ok
:=
rs
.
m
[
k
]
_
,
ok
:=
rs
.
providers
[
k
]
if
!
ok
{
rs
.
m
[
k
]
=
make
(
map
[
*
peer
.
Peer
]
bool
)
rs
.
providers
[
k
]
=
make
(
peer
.
Map
)
}
rs
.
m
[
k
][
p
]
=
true
rs
.
providers
[
k
][
p
.
Key
()]
=
p
return
nil
}
...
...
@@ -51,11 +51,11 @@ func (rs *hashTable) Providers(k u.Key) []*peer.Peer {
rs
.
lock
.
RLock
()
defer
rs
.
lock
.
RUnlock
()
ret
:=
make
([]
*
peer
.
Peer
,
0
)
peerset
,
ok
:=
rs
.
m
[
k
]
peerset
,
ok
:=
rs
.
providers
[
k
]
if
!
ok
{
return
ret
}
for
peer
,
_
:=
range
peerset
{
for
_
,
peer
:=
range
peerset
{
ret
=
append
(
ret
,
peer
)
}
return
ret
...
...
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