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
60f3a874
Commit
60f3a874
authored
Dec 23, 2014
by
Brian Tiger Chow
Committed by
Juan Batiz-Benet
Dec 23, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(bitswap/network) expose peerstore
parent
a225568f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
3 deletions
+15
-3
exchange/bitswap/network/interface.go
exchange/bitswap/network/interface.go
+2
-0
exchange/bitswap/network/ipfs_impl.go
exchange/bitswap/network/ipfs_impl.go
+4
-0
exchange/bitswap/testnet/network.go
exchange/bitswap/testnet/network.go
+9
-3
No files found.
exchange/bitswap/network/interface.go
View file @
60f3a874
...
...
@@ -26,6 +26,8 @@ type BitSwapNetwork interface {
peer
.
ID
,
bsmsg
.
BitSwapMessage
)
(
incoming
bsmsg
.
BitSwapMessage
,
err
error
)
Peerstore
()
peer
.
Peerstore
// SetDelegate registers the Reciver to handle messages received from the
// network.
SetDelegate
(
Receiver
)
...
...
exchange/bitswap/network/ipfs_impl.go
View file @
60f3a874
...
...
@@ -70,6 +70,10 @@ func (bsnet *impl) SetDelegate(r Receiver) {
bsnet
.
receiver
=
r
}
func
(
bsnet
*
impl
)
Peerstore
()
peer
.
Peerstore
{
return
bsnet
.
Peerstore
()
}
// handleNewStream receives a new stream from the network.
func
(
bsnet
*
impl
)
handleNewStream
(
s
inet
.
Stream
)
{
...
...
exchange/bitswap/testnet/network.go
View file @
60f3a874
...
...
@@ -47,8 +47,9 @@ type network struct {
func
(
n
*
network
)
Adapter
(
p
peer
.
ID
)
bsnet
.
BitSwapNetwork
{
client
:=
&
networkClient
{
local
:
p
,
network
:
n
,
local
:
p
,
network
:
n
,
peerstore
:
peer
.
NewPeerstore
(),
}
n
.
clients
[
p
]
=
client
return
client
...
...
@@ -148,7 +149,8 @@ func (n *network) SendRequest(
type
networkClient
struct
{
local
peer
.
ID
bsnet
.
Receiver
network
Network
network
Network
peerstore
peer
.
Peerstore
}
func
(
nc
*
networkClient
)
SendMessage
(
...
...
@@ -176,3 +178,7 @@ func (nc *networkClient) DialPeer(ctx context.Context, p peer.ID) error {
func
(
nc
*
networkClient
)
SetDelegate
(
r
bsnet
.
Receiver
)
{
nc
.
Receiver
=
r
}
func
(
nc
*
networkClient
)
Peerstore
()
peer
.
Peerstore
{
return
nc
.
peerstore
}
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