mirror of
https://github.com/ipfs/kubo.git
synced 2025-06-25 06:58:18 +08:00
muxer construction
This commit is contained in:

committed by
Brian Tiger Chow

parent
700b6ab99f
commit
313f3c83c8
@ -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{
|
||||
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{
|
||||
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{
|
||||
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,
|
||||
}
|
||||
|
Reference in New Issue
Block a user