提交 ec7116ac 作者: vyzo 提交者: Łukasz Magiera

namecache: make feature experimental with --enable-follow-experiment

License: MIT
Signed-off-by: 's avatarvyzo <vyzo@hackzen.org>
上级 40545856
......@@ -55,6 +55,7 @@ const (
enablePubSubKwd = "enable-pubsub-experiment"
enableIPNSPubSubKwd = "enable-namesys-pubsub"
enableMultiplexKwd = "enable-mplex-experiment"
enableFollowKwd = "enable-follow-experiment"
// apiAddrKwd = "address-api"
// swarmAddrKwd = "address-swarm"
)
......@@ -167,6 +168,7 @@ Headers.
cmdkit.BoolOption(enablePubSubKwd, "Instantiate the ipfs daemon with the experimental pubsub feature enabled."),
cmdkit.BoolOption(enableIPNSPubSubKwd, "Enable IPNS record distribution through pubsub; enables pubsub."),
cmdkit.BoolOption(enableMultiplexKwd, "Add the experimental 'go-multiplex' stream muxer to libp2p on construction.").WithDefault(true),
cmdkit.BoolOption(enableFollowKwd, "Enable IPNS name following."),
// TODO: add way to override addresses. tricky part: updating the config if also --init.
// cmdkit.StringOption(apiAddrKwd, "Address for the daemon rpc API (overrides config)"),
......@@ -287,6 +289,7 @@ func daemonFunc(req *cmds.Request, re cmds.ResponseEmitter, env cmds.Environment
ipnsps, _ := req.Options[enableIPNSPubSubKwd].(bool)
pubsub, _ := req.Options[enablePubSubKwd].(bool)
mplex, _ := req.Options[enableMultiplexKwd].(bool)
follow, _ := req.Option(enableFollowKwd).Bool()
// Start assembling node config
ncfg := &core.BuildCfg{
......@@ -298,6 +301,7 @@ func daemonFunc(req *cmds.Request, re cmds.ResponseEmitter, env cmds.Environment
"pubsub": pubsub,
"ipnsps": ipnsps,
"mplex": mplex,
"follow": follow,
},
//TODO(Kubuxu): refactor Online vs Offline by adding Permanent vs Ephemeral
}
......
......@@ -256,7 +256,7 @@ func setupNode(ctx context.Context, n *IpfsNode, cfg *BuildCfg) error {
if cfg.Online {
do := setupDiscoveryOption(rcfg.Discovery)
if err := n.startOnlineServices(ctx, cfg.Routing, hostOption, do, cfg.getOpt("pubsub"), cfg.getOpt("ipnsps"), cfg.getOpt("mplex")); err != nil {
if err := n.startOnlineServices(ctx, cfg.Routing, hostOption, do, cfg.getOpt("pubsub"), cfg.getOpt("ipnsps"), cfg.getOpt("mplex"), cfg.getOpt("follow")); err != nil {
return err
}
} else {
......
......@@ -159,7 +159,7 @@ type Mounts struct {
Ipns mount.Mount
}
func (n *IpfsNode) startOnlineServices(ctx context.Context, routingOption RoutingOption, hostOption HostOption, do DiscoveryOption, pubsub, ipnsps, mplex bool) error {
func (n *IpfsNode) startOnlineServices(ctx context.Context, routingOption RoutingOption, hostOption HostOption, do DiscoveryOption, pubsub, ipnsps, mplex, follow bool) error {
if n.PeerHost != nil { // already online.
return errors.New("node already online")
}
......@@ -295,6 +295,10 @@ func (n *IpfsNode) startOnlineServices(ctx context.Context, routingOption Routin
n.P2P = p2p.NewP2P(n.Identity, n.PeerHost, n.Peerstore)
if follow {
n.Namecache = namecache.NewNameCache(ctx, n.Namesys, n.Pinning, n.DAG, n.Blockstore)
}
// setup local discovery
if do != nil {
service, err := do(ctx, n.PeerHost)
......@@ -590,7 +594,6 @@ func (n *IpfsNode) startOnlineServicesWithHost(ctx context.Context, routingOptio
// setup name system
n.Namesys = namesys.NewNameSystem(n.Routing, n.Repo.Datastore(), size)
n.Namecache = namecache.NewNameCache(ctx, n.Namesys, n.Pinning, n.DAG, n.Blockstore)
// setup ipns republishing
return n.setupIpnsRepublisher()
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论