Commit 313f3c83 authored by Juan Batiz-Benet's avatar Juan Batiz-Benet Committed by Brian Tiger Chow

muxer construction

parent 700b6ab9
......@@ -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
......
......@@ -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")
......
......@@ -36,7 +36,7 @@ func NewIpfsNetwork(ctx context.Context, local *peer.Peer,
in := &IpfsNetwork{
local: local,
muxer: &mux.Muxer{Protocols: *pmap},
muxer: mux.NewMuxer(*pmap),
ctx: ctx,
cancel: cancel,
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment