@cryptotaxi247 / kubo / commits / 2984fb72d

add relaying to mocknet

These services should all be added separately, in a function that is Network impl independent. The interfaces need to be massaged a bit (split inet.Network in two), so will do when needed. For now this is fine.

Juan Batiz-Benet committed Dec 28, 2014 at 07:03 UTC 2984fb72d6c612187326d4c9d275b4909d571ae9
1 file changed +7 -2
net/mock/mock_peernet.go
+7 -2
@@ -9,6 +9,7 @@ import (
9 inet "github.com/jbenet/go-ipfs/net"
10 ids "github.com/jbenet/go-ipfs/net/services/identify"
11 mux "github.com/jbenet/go-ipfs/net/services/mux"
12 + relay "github.com/jbenet/go-ipfs/net/services/relay"
13 peer "github.com/jbenet/go-ipfs/peer"
14
15 context "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context"
@@ -30,8 +31,9 @@ type peernet struct {
31 connsByLink map[*link]map[*conn]struct{}
32
33 // needed to implement inet.Network
33 - mux mux.Mux
34 - ids *ids.IDService
34 + mux mux.Mux
35 + ids *ids.IDService
36 + relay *relay.RelayService
37
38 cg ctxgroup.ContextGroup
39 sync.RWMutex
@@ -69,6 +71,9 @@ func newPeernet(ctx context.Context, m *mocknet, k ic.PrivKey,
71 // this is ProtocolIdentify.
72 n.ids = ids.NewIDService(n)
73
74 + // setup ProtocolRelay to allow traffic relaying.
75 + // Feed things we get for ourselves into the muxer.
76 + n.relay = relay.NewRelayService(n.cg.Context(), n, n.mux.HandleSync)
77 return n, nil
78 }
79