1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-07-02 20:32:58 +08:00

core is now ctxcloser

This commit is contained in:
Juan Batiz-Benet
2014-10-25 05:59:37 -07:00
parent 90b989a718
commit 8cf22c062f
2 changed files with 24 additions and 18 deletions

View File

@ -26,6 +26,7 @@ import (
routing "github.com/jbenet/go-ipfs/routing" routing "github.com/jbenet/go-ipfs/routing"
dht "github.com/jbenet/go-ipfs/routing/dht" dht "github.com/jbenet/go-ipfs/routing/dht"
u "github.com/jbenet/go-ipfs/util" u "github.com/jbenet/go-ipfs/util"
ctxc "github.com/jbenet/go-ipfs/util/ctxcloser"
) )
var log = u.Logger("core") var log = u.Logger("core")
@ -71,6 +72,8 @@ type IpfsNode struct {
// the pinning manager // the pinning manager
Pinning pin.Pinner Pinning pin.Pinner
ctxc.ContextCloser
} }
// NewIpfsNode constructs a new IpfsNode based on the given config. // NewIpfsNode constructs a new IpfsNode based on the given config.
@ -159,21 +162,25 @@ func NewIpfsNode(cfg *config.Config, online bool) (*IpfsNode, error) {
} }
success = true success = true
return &IpfsNode{ n := &IpfsNode{
Config: cfg, Config: cfg,
Peerstore: peerstore, Peerstore: peerstore,
Datastore: d, Datastore: d,
Blocks: bs, Blocks: bs,
DAG: dag, DAG: dag,
Resolver: &path.Resolver{DAG: dag}, Resolver: &path.Resolver{DAG: dag},
Exchange: exchangeSession, Exchange: exchangeSession,
Identity: local, Identity: local,
Routing: route, Routing: route,
Namesys: ns, Namesys: ns,
Diagnostics: diagnostics, Diagnostics: diagnostics,
Network: network, Network: network,
Pinning: p, Pinning: p,
}, nil ContextCloser: ctxc.NewContextCloser(ctx, nil),
}
n.AddCloserChild(n.Network)
return n, nil
} }
func initIdentity(cfg *config.Config, peers peer.Peerstore, online bool) (peer.Peer, error) { func initIdentity(cfg *config.Config, peers peer.Peerstore, online bool) (peer.Peer, error) {

View File

@ -5,10 +5,12 @@ import (
mux "github.com/jbenet/go-ipfs/net/mux" mux "github.com/jbenet/go-ipfs/net/mux"
srv "github.com/jbenet/go-ipfs/net/service" srv "github.com/jbenet/go-ipfs/net/service"
peer "github.com/jbenet/go-ipfs/peer" peer "github.com/jbenet/go-ipfs/peer"
ctxc "github.com/jbenet/go-ipfs/util/ctxcloser"
) )
// Network is the interface IPFS uses for connecting to the world. // Network is the interface IPFS uses for connecting to the world.
type Network interface { type Network interface {
ctxc.ContextCloser
// Listen handles incoming connections on given Multiaddr. // Listen handles incoming connections on given Multiaddr.
// Listen(*ma.Muliaddr) error // Listen(*ma.Muliaddr) error
@ -35,9 +37,6 @@ type Network interface {
// SendMessage sends given Message out // SendMessage sends given Message out
SendMessage(msg.NetMessage) error SendMessage(msg.NetMessage) error
// Close terminates all network operation
Close() error
} }
// Sender interface for network services. // Sender interface for network services.