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:
11
core/core.go
11
core/core.go
@ -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,7 +162,7 @@ func NewIpfsNode(cfg *config.Config, online bool) (*IpfsNode, error) {
|
||||
}
|
||||
|
||||
success = true
|
||||
return &IpfsNode{
|
||||
n := &IpfsNode{
|
||||
Config: cfg,
|
||||
Peerstore: peerstore,
|
||||
Datastore: d,
|
||||
@ -173,7 +176,11 @@ func NewIpfsNode(cfg *config.Config, online bool) (*IpfsNode, error) {
|
||||
Diagnostics: diagnostics,
|
||||
Network: network,
|
||||
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) {
|
||||
|
@ -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.
|
||||
|
Reference in New Issue
Block a user