1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-07-01 02:30:39 +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"
dht "github.com/jbenet/go-ipfs/routing/dht"
u "github.com/jbenet/go-ipfs/util"
ctxc "github.com/jbenet/go-ipfs/util/ctxcloser"
)
var log = u.Logger("core")
@ -71,6 +72,8 @@ type IpfsNode struct {
// the pinning manager
Pinning pin.Pinner
ctxc.ContextCloser
}
// 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
return &IpfsNode{
Config: cfg,
Peerstore: peerstore,
Datastore: d,
Blocks: bs,
DAG: dag,
Resolver: &path.Resolver{DAG: dag},
Exchange: exchangeSession,
Identity: local,
Routing: route,
Namesys: ns,
Diagnostics: diagnostics,
Network: network,
Pinning: p,
}, nil
n := &IpfsNode{
Config: cfg,
Peerstore: peerstore,
Datastore: d,
Blocks: bs,
DAG: dag,
Resolver: &path.Resolver{DAG: dag},
Exchange: exchangeSession,
Identity: local,
Routing: route,
Namesys: ns,
Diagnostics: diagnostics,
Network: network,
Pinning: p,
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) {

View File

@ -5,10 +5,12 @@ import (
mux "github.com/jbenet/go-ipfs/net/mux"
srv "github.com/jbenet/go-ipfs/net/service"
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.
type Network interface {
ctxc.ContextCloser
// Listen handles incoming connections on given Multiaddr.
// Listen(*ma.Muliaddr) error
@ -35,9 +37,6 @@ type Network interface {
// SendMessage sends given Message out
SendMessage(msg.NetMessage) error
// Close terminates all network operation
Close() error
}
// Sender interface for network services.