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-unixfs
Commits
313f3c83
Commit
313f3c83
authored
Sep 18, 2014
by
Juan Batiz-Benet
Committed by
Brian Tiger Chow
Sep 22, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
muxer construction
parent
700b6ab9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
23 deletions
+22
-23
net/mux/mux.go
net/mux/mux.go
+8
-0
net/mux/mux_test.go
net/mux/mux_test.go
+13
-22
net/net.go
net/net.go
+1
-1
No files found.
net/mux/mux.go
View file @
313f3c83
...
...
@@ -34,6 +34,14 @@ type Muxer struct {
*
msg
.
Pipe
}
// NewMuxer constructs a muxer given a protocol map.
func
NewMuxer
(
mp
ProtocolMap
)
*
Muxer
{
return
&
Muxer
{
Protocols
:
mp
,
Pipe
:
msg
.
NewPipe
(
10
),
}
}
// GetPipe implements the Protocol interface
func
(
m
*
Muxer
)
GetPipe
()
*
msg
.
Pipe
{
return
m
.
Pipe
...
...
net/mux/mux_test.go
View file @
313f3c83
...
...
@@ -6,10 +6,10 @@ import (
"testing"
"time"
mh
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multihash"
msg
"github.com/jbenet/go-ipfs/net/message"
peer
"github.com/jbenet/go-ipfs/peer"
u
"github.com/jbenet/go-ipfs/util"
mh
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multihash"
context
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context"
)
...
...
@@ -60,13 +60,10 @@ func TestSimpleMuxer(t *testing.T) {
p2
:=
&
TestProtocol
{
Pipe
:
msg
.
NewPipe
(
10
)}
pid1
:=
ProtocolID_Test
pid2
:=
ProtocolID_Routing
mux1
:=
&
Muxer
{
Pipe
:
msg
.
NewPipe
(
10
),
Protocols
:
ProtocolMap
{
pid1
:
p1
,
pid2
:
p2
,
},
}
mux1
:=
NewMuxer
(
ProtocolMap
{
pid1
:
p1
,
pid2
:
p2
,
})
peer1
:=
newPeer
(
t
,
"11140beec7b5ea3f0fdbc95d0dd47f3c5bc275aaaaaa"
)
// peer2 := newPeer(t, "11140beec7b5ea3f0fdbc95d0dd47f3c5bc275bbbbbb")
...
...
@@ -114,13 +111,10 @@ func TestSimultMuxer(t *testing.T) {
p2
:=
&
TestProtocol
{
Pipe
:
msg
.
NewPipe
(
10
)}
pid1
:=
ProtocolID_Test
pid2
:=
ProtocolID_Identify
mux1
:=
&
Muxer
{
Pipe
:
msg
.
NewPipe
(
10
),
Protocols
:
ProtocolMap
{
pid1
:
p1
,
pid2
:
p2
,
},
}
mux1
:=
NewMuxer
(
ProtocolMap
{
pid1
:
p1
,
pid2
:
p2
,
})
peer1
:=
newPeer
(
t
,
"11140beec7b5ea3f0fdbc95d0dd47f3c5bc275aaaaaa"
)
// peer2 := newPeer(t, "11140beec7b5ea3f0fdbc95d0dd47f3c5bc275bbbbbb")
...
...
@@ -224,13 +218,10 @@ func TestStopping(t *testing.T) {
p2
:=
&
TestProtocol
{
Pipe
:
msg
.
NewPipe
(
10
)}
pid1
:=
ProtocolID_Test
pid2
:=
ProtocolID_Identify
mux1
:=
&
Muxer
{
Pipe
:
msg
.
NewPipe
(
10
),
Protocols
:
ProtocolMap
{
pid1
:
p1
,
pid2
:
p2
,
},
}
mux1
:=
NewMuxer
(
ProtocolMap
{
pid1
:
p1
,
pid2
:
p2
,
})
peer1
:=
newPeer
(
t
,
"11140beec7b5ea3f0fdbc95d0dd47f3c5bc275aaaaaa"
)
// peer2 := newPeer(t, "11140beec7b5ea3f0fdbc95d0dd47f3c5bc275bbbbbb")
...
...
net/net.go
View file @
313f3c83
...
...
@@ -36,7 +36,7 @@ func NewIpfsNetwork(ctx context.Context, local *peer.Peer,
in
:=
&
IpfsNetwork
{
local
:
local
,
muxer
:
&
mux
.
Muxer
{
Protocols
:
*
pmap
}
,
muxer
:
mux
.
New
Muxer
(
*
pmap
)
,
ctx
:
ctx
,
cancel
:
cancel
,
}
...
...
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