提交 bfaffb2d 作者: Łukasz Magiera 提交者: Steven Allen

Fix bootstrap

License: MIT
Signed-off-by: 's avatarŁukasz Magiera <magik6k@gmail.com>
上级 cc2be2e7
...@@ -245,18 +245,18 @@ func NewNode(ctx context.Context, cfg *BuildCfg) (*IpfsNode, error) { ...@@ -245,18 +245,18 @@ func NewNode(ctx context.Context, cfg *BuildCfg) (*IpfsNode, error) {
n.IsOnline = cfg.Online n.IsOnline = cfg.Online
n.app = app n.app = app
/* n := &IpfsNode{ /* n := &IpfsNode{
IsOnline: cfg.Online, IsOnline: cfg.Online,
Repo: cfg.Repo, Repo: cfg.Repo,
ctx: ctx, ctx: ctx,
Peerstore: pstoremem.NewPeerstore(), Peerstore: pstoremem.NewPeerstore(),
} }
n.RecordValidator = record.NamespacedValidator{ n.RecordValidator = record.NamespacedValidator{
"pk": record.PublicKeyValidator{}, "pk": record.PublicKeyValidator{},
"ipns": ipns.Validator{KeyBook: n.Peerstore}, "ipns": ipns.Validator{KeyBook: n.Peerstore},
} }
*/ */
// TODO: port to lifetimes // TODO: port to lifetimes
// n.proc = goprocessctx.WithContextAndTeardown(ctx, n.teardown) // n.proc = goprocessctx.WithContextAndTeardown(ctx, n.teardown)
...@@ -264,11 +264,20 @@ func NewNode(ctx context.Context, cfg *BuildCfg) (*IpfsNode, error) { ...@@ -264,11 +264,20 @@ func NewNode(ctx context.Context, cfg *BuildCfg) (*IpfsNode, error) {
n.Close() n.Close()
return nil, err return nil, err
}*/ }*/
if app.Err() != nil { if app.Err() != nil {
return nil, app.Err() return nil, app.Err()
} }
if err := app.Start(ctx); err != nil {
return nil, err
}
// TODO: DI-ify bootstrap
if !cfg.Online {
return n, nil
}
return n, app.Start(ctx) return n, n.Bootstrap(DefaultBootstrapConfig)
} }
func isTooManyFDError(err error) bool { func isTooManyFDError(err error) bool {
......
...@@ -100,13 +100,13 @@ type IpfsNode struct { ...@@ -100,13 +100,13 @@ type IpfsNode struct {
Repo repo.Repo Repo repo.Repo
// Local node // Local node
Pinning pin.Pinner // the pinning manager Pinning pin.Pinner // the pinning manager
Mounts Mounts `optional:"true"` // current mount state, if any. Mounts Mounts `optional:"true"` // current mount state, if any.
PrivateKey ic.PrivKey // the local node's private Key PrivateKey ic.PrivKey // the local node's private Key
PNetFingerprint PNetFingerprint `optional:"true"` // fingerprint of private network PNetFingerprint PNetFingerprint `optional:"true"` // fingerprint of private network
// Services // Services
Peerstore pstore.Peerstore `optional:"true"` // storage for other Peer instances Peerstore pstore.Peerstore `optional:"true"` // storage for other Peer instances
Blockstore bstore.GCBlockstore // the block store (lower level) Blockstore bstore.GCBlockstore // the block store (lower level)
Filestore *filestore.Filestore // the filestore blockstore Filestore *filestore.Filestore // the filestore blockstore
BaseBlocks bstore.Blockstore // the raw blockstore, no filestore wrapping BaseBlocks bstore.Blockstore // the raw blockstore, no filestore wrapping
...@@ -114,35 +114,35 @@ type IpfsNode struct { ...@@ -114,35 +114,35 @@ type IpfsNode struct {
Blocks bserv.BlockService // the block service, get/add blocks. Blocks bserv.BlockService // the block service, get/add blocks.
DAG ipld.DAGService // the merkle dag service, get/add objects. DAG ipld.DAGService // the merkle dag service, get/add objects.
Resolver *resolver.Resolver // the path resolution system Resolver *resolver.Resolver // the path resolution system
Reporter metrics.Reporter `optional:"true"` Reporter metrics.Reporter `optional:"true"`
Discovery discovery.Service `optional:"true"` Discovery discovery.Service `optional:"true"`
FilesRoot *mfs.Root FilesRoot *mfs.Root
RecordValidator record.Validator RecordValidator record.Validator
// Online // Online
PeerHost p2phost.Host `optional:"true"` // the network host (server+client) PeerHost p2phost.Host `optional:"true"` // the network host (server+client)
Bootstrapper io.Closer `optional:"true"` // the periodic bootstrapper Bootstrapper io.Closer `optional:"true"` // the periodic bootstrapper
Routing routing.IpfsRouting `optional:"true"` // the routing system. recommend ipfs-dht Routing routing.IpfsRouting `optional:"true"` // the routing system. recommend ipfs-dht
Exchange exchange.Interface // the block exchange + strategy (bitswap) Exchange exchange.Interface // the block exchange + strategy (bitswap)
Namesys namesys.NameSystem // the name system, resolves paths to hashes Namesys namesys.NameSystem // the name system, resolves paths to hashes
Provider provider.Provider // the value provider system Provider provider.Provider // the value provider system
Reprovider *rp.Reprovider `optional:"true"` // the value reprovider system Reprovider *rp.Reprovider `optional:"true"` // the value reprovider system
IpnsRepub *ipnsrp.Republisher `optional:"true"` IpnsRepub *ipnsrp.Republisher `optional:"true"`
AutoNAT *autonat.AutoNATService `optional:"true"` AutoNAT *autonat.AutoNATService `optional:"true"`
PubSub *pubsub.PubSub `optional:"true"` PubSub *pubsub.PubSub `optional:"true"`
PSRouter *psrouter.PubsubValueStore `optional:"true"` PSRouter *psrouter.PubsubValueStore `optional:"true"`
DHT *dht.IpfsDHT `optional:"true"` DHT *dht.IpfsDHT `optional:"true"`
P2P *p2p.P2P `optional:"true"` P2P *p2p.P2P `optional:"true"`
Process goprocess.Process Process goprocess.Process
ctx context.Context ctx context.Context
app *fx.App app *fx.App
// Flags // Flags
IsOnline bool `optional:"true"` // Online is set when networking is enabled. IsOnline bool `optional:"true"` // Online is set when networking is enabled.
IsDaemon bool `optional:"true"` // Daemon is set when running on a long-running daemon. IsDaemon bool `optional:"true"` // Daemon is set when running on a long-running daemon.
} }
// Mounts defines what the node's mount state is. This should // Mounts defines what the node's mount state is. This should
...@@ -206,9 +206,9 @@ func (n *IpfsNode) startOnlineServices(ctx context.Context, routingOption Routin ...@@ -206,9 +206,9 @@ func (n *IpfsNode) startOnlineServices(ctx context.Context, routingOption Routin
log.Warning("This might be configuration mistake.") log.Warning("This might be configuration mistake.")
} }
} }
//case <-n.Process().Closing(): //case <-n.Process().Closing():
// t.Stop() // t.Stop()
// return // return
} }
} }
}() }()
......
...@@ -452,11 +452,11 @@ func p2pHost(lc fx.Lifecycle, params p2pHostIn) (out p2pHostOut, err error) { ...@@ -452,11 +452,11 @@ func p2pHost(lc fx.Lifecycle, params p2pHostIn) (out p2pHostOut, err error) {
type p2pRoutingIn struct { type p2pRoutingIn struct {
fx.In fx.In
BCfg *BuildCfg BCfg *BuildCfg
Repo repo.Repo Repo repo.Repo
Validator record.Validator Validator record.Validator
Host p2phost.Host Host p2phost.Host
PubSub *pubsub.PubSub PubSub *pubsub.PubSub
BaseRouting BaseRouting BaseRouting BaseRouting
} }
...@@ -553,7 +553,6 @@ func offlineNamesysCtor(rt routing.IpfsRouting, repo repo.Repo) (namesys.NameSys ...@@ -553,7 +553,6 @@ func offlineNamesysCtor(rt routing.IpfsRouting, repo repo.Repo) (namesys.NameSys
return namesys.NewNameSystem(rt, repo.Datastore(), 0), nil return namesys.NewNameSystem(rt, repo.Datastore(), 0), nil
} }
//////////// ////////////
// IPFS services // IPFS services
...@@ -621,7 +620,7 @@ func ipnsRepublisher(lc lcProcess, cfg *iconfig.Config, namesys namesys.NameSyst ...@@ -621,7 +620,7 @@ func ipnsRepublisher(lc lcProcess, cfg *iconfig.Config, namesys namesys.NameSyst
} }
type discoveryHandler struct { type discoveryHandler struct {
ctx context.Context ctx context.Context
host p2phost.Host host p2phost.Host
} }
...@@ -636,7 +635,7 @@ func (dh *discoveryHandler) HandlePeerFound(p pstore.PeerInfo) { ...@@ -636,7 +635,7 @@ func (dh *discoveryHandler) HandlePeerFound(p pstore.PeerInfo) {
func newDiscoveryHandler(lc fx.Lifecycle, host p2phost.Host) *discoveryHandler { func newDiscoveryHandler(lc fx.Lifecycle, host p2phost.Host) *discoveryHandler {
return &discoveryHandler{ return &discoveryHandler{
ctx: lifecycleCtx(lc), ctx: lifecycleCtx(lc),
host: host, host: host,
} }
} }
...@@ -739,11 +738,6 @@ func files(lc fx.Lifecycle, repo repo.Repo, dag format.DAGService) (*mfs.Root, e ...@@ -739,11 +738,6 @@ func files(lc fx.Lifecycle, repo repo.Repo, dag format.DAGService) (*mfs.Root, e
return mfs.NewRoot(ctx, dag, nd, pf) return mfs.NewRoot(ctx, dag, nd, pf)
} }
// TODO !!!!!!!!
func bootstrap(n IpfsNode) error {
return n.Bootstrap(DefaultBootstrapConfig)
}
//////////// ////////////
// Hacks // Hacks
...@@ -765,7 +759,7 @@ func lifecycleCtx(lc fx.Lifecycle) context.Context { ...@@ -765,7 +759,7 @@ func lifecycleCtx(lc fx.Lifecycle) context.Context {
type lcProcess struct { type lcProcess struct {
fx.In fx.In
LC fx.Lifecycle LC fx.Lifecycle
Proc goprocess.Process Proc goprocess.Process
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论