@cryptotaxi247 / kubo / commits / b720d1f0b

uses the global PeerHost and don't expose the P2P one

License: MIT Signed-off-by: Steven Allen <steven@stebalien.com>

Steven Allen committed Nov 12, 2018 at 16:21 UTC b720d1f0b58321ff209131ef8de04ce53ea093e6
3 files changed +8 -8
core/corehttp/proxy.go
+1 -1
@@ -33,7 +33,7 @@ func ProxyOption() ServeOption {
33 return
34 }
35
36 - rt := p2phttp.NewTransport(ipfsNode.P2P.PeerHost, p2phttp.ProtocolOption(parsedRequest.name))
36 + rt := p2phttp.NewTransport(ipfsNode.PeerHost, p2phttp.ProtocolOption(parsedRequest.name))
37 proxy := httputil.NewSingleHostReverseProxy(target)
38 proxy.Transport = rt
39 proxy.ServeHTTP(w, request)
p2p/local.go
+1 -1
@@ -55,7 +55,7 @@ func (l *localListener) dial(ctx context.Context) (net.Stream, error) {
55 cctx, cancel := context.WithTimeout(ctx, time.Second*30) //TODO: configurable?
56 defer cancel()
57
58 - return l.p2p.PeerHost.NewStream(cctx, l.peer, l.proto)
58 + return l.p2p.peerHost.NewStream(cctx, l.peer, l.proto)
59 }
60
61 func (l *localListener) acceptConns() {
p2p/p2p.go
+6 -6
@@ -16,23 +16,23 @@ type P2P struct {
16 Streams *StreamRegistry
17
18 identity peer.ID
19 - PeerHost p2phost.Host
19 + peerHost p2phost.Host
20 peerstore pstore.Peerstore
21 }
22
23 // NewP2P creates new P2P struct
24 -func NewP2P(identity peer.ID, PeerHost p2phost.Host, peerstore pstore.Peerstore) *P2P {
24 +func NewP2P(identity peer.ID, peerHost p2phost.Host, peerstore pstore.Peerstore) *P2P {
25 return &P2P{
26 identity: identity,
27 - PeerHost: PeerHost,
27 + peerHost: peerHost,
28 peerstore: peerstore,
29
30 ListenersLocal: newListenersLocal(),
31 - ListenersP2P: newListenersP2P(PeerHost),
31 + ListenersP2P: newListenersP2P(peerHost),
32
33 Streams: &StreamRegistry{
34 Streams: map[uint64]*Stream{},
35 - ConnManager: PeerHost.ConnManager(),
35 + ConnManager: peerHost.ConnManager(),
36 conns: map[peer.ID]int{},
37 },
38 }
@@ -41,7 +41,7 @@ func NewP2P(identity peer.ID, PeerHost p2phost.Host, peerstore pstore.Peerstore)
41 // CheckProtoExists checks whether a proto handler is registered to
42 // mux handler
43 func (p2p *P2P) CheckProtoExists(proto string) bool {
44 - protos := p2p.PeerHost.Mux().Protocols()
44 + protos := p2p.peerHost.Mux().Protocols()
45
46 for _, p := range protos {
47 if p != proto {