@cryptotaxi247 / kubo / commits / 8cf22c062

core is now ctxcloser

Juan Batiz-Benet committed Oct 25, 2014 at 05:59 UTC 8cf22c062fce116cc7bad103039097ffb54b8218
2 files changed +24 -18
core/core.go
+22 -15
@@ -26,6 +26,7 @@ import (
26 routing "github.com/jbenet/go-ipfs/routing"
27 dht "github.com/jbenet/go-ipfs/routing/dht"
28 u "github.com/jbenet/go-ipfs/util"
29 + ctxc "github.com/jbenet/go-ipfs/util/ctxcloser"
30 )
31
32 var log = u.Logger("core")
@@ -71,6 +72,8 @@ type IpfsNode struct {
72
73 // the pinning manager
74 Pinning pin.Pinner
75 +
76 + ctxc.ContextCloser
77 }
78
79 // NewIpfsNode constructs a new IpfsNode based on the given config.
@@ -159,21 +162,25 @@ func NewIpfsNode(cfg *config.Config, online bool) (*IpfsNode, error) {
162 }
163
164 success = true
162 - return &IpfsNode{
163 - Config: cfg,
164 - Peerstore: peerstore,
165 - Datastore: d,
166 - Blocks: bs,
167 - DAG: dag,
168 - Resolver: &path.Resolver{DAG: dag},
169 - Exchange: exchangeSession,
170 - Identity: local,
171 - Routing: route,
172 - Namesys: ns,
173 - Diagnostics: diagnostics,
174 - Network: network,
175 - Pinning: p,
176 - }, nil
165 + n := &IpfsNode{
166 + Config: cfg,
167 + Peerstore: peerstore,
168 + Datastore: d,
169 + Blocks: bs,
170 + DAG: dag,
171 + Resolver: &path.Resolver{DAG: dag},
172 + Exchange: exchangeSession,
173 + Identity: local,
174 + Routing: route,
175 + Namesys: ns,
176 + Diagnostics: diagnostics,
177 + Network: network,
178 + Pinning: p,
179 + ContextCloser: ctxc.NewContextCloser(ctx, nil),
180 + }
181 +
182 + n.AddCloserChild(n.Network)
183 + return n, nil
184 }
185
186 func initIdentity(cfg *config.Config, peers peer.Peerstore, online bool) (peer.Peer, error) {
net/interface.go
+2 -3
@@ -5,10 +5,12 @@ import (
5 mux "github.com/jbenet/go-ipfs/net/mux"
6 srv "github.com/jbenet/go-ipfs/net/service"
7 peer "github.com/jbenet/go-ipfs/peer"
8 + ctxc "github.com/jbenet/go-ipfs/util/ctxcloser"
9 )
10
11 // Network is the interface IPFS uses for connecting to the world.
12 type Network interface {
13 + ctxc.ContextCloser
14
15 // Listen handles incoming connections on given Multiaddr.
16 // Listen(*ma.Muliaddr) error
@@ -35,9 +37,6 @@ type Network interface {
37
38 // SendMessage sends given Message out
39 SendMessage(msg.NetMessage) error
38 -
39 - // Close terminates all network operation
40 - Close() error
40 }
41
42 // Sender interface for network services.