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
f15ab8ee
Commit
f15ab8ee
authored
Nov 21, 2014
by
Juan Batiz-Benet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
net: add LocalPeer funcs
parent
ff1e672d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
0 deletions
+15
-0
net/interface.go
net/interface.go
+5
-0
net/net.go
net/net.go
+5
-0
net/swarm/swarm.go
net/swarm/swarm.go
+5
-0
No files found.
net/interface.go
View file @
f15ab8ee
...
...
@@ -20,6 +20,9 @@ type Network interface {
// Listen(*ma.Muliaddr) error
// TODO: for now, only listen on addrs in local peer when initializing.
// LocalPeer returns the local peer associated with this network
LocalPeer
()
peer
.
Peer
// DialPeer attempts to establish a connection to a given peer
DialPeer
(
context
.
Context
,
peer
.
Peer
)
error
...
...
@@ -71,6 +74,8 @@ type Service srv.Service
// (this is usually just a Network, but other services may not need the whole
// stack, and thus it becomes easier to mock)
type
Dialer
interface
{
// LocalPeer returns the local peer associated with this network
LocalPeer
()
peer
.
Peer
// DialPeer attempts to establish a connection to a given peer
DialPeer
(
context
.
Context
,
peer
.
Peer
)
error
...
...
net/net.go
View file @
f15ab8ee
...
...
@@ -69,6 +69,11 @@ func (n *IpfsNetwork) DialPeer(ctx context.Context, p peer.Peer) error {
return
err
}
// LocalPeer the network's LocalPeer
func
(
n
*
IpfsNetwork
)
LocalPeer
()
peer
.
Peer
{
return
n
.
swarm
.
LocalPeer
()
}
// ClosePeer connection to peer
func
(
n
*
IpfsNetwork
)
ClosePeer
(
p
peer
.
Peer
)
error
{
return
n
.
swarm
.
CloseConnection
(
p
)
...
...
net/swarm/swarm.go
View file @
f15ab8ee
...
...
@@ -217,3 +217,8 @@ func (s *Swarm) GetPeerList() []peer.Peer {
s
.
connsLock
.
RUnlock
()
return
out
}
// LocalPeer returns the local peer swarm is associated to.
func
(
s
*
Swarm
)
LocalPeer
()
peer
.
Peer
{
return
s
.
local
}
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