I’m trying to adopt this example to my needs and current state of libraries:
I’m able to start temporary node and some basic activity but I can’t use pubsub feature.
It is enabled in config with cfg.Pubsub.Enabled=1:
// Create a config with default options and a 2048 bit key
cfg, err := config.Init(ioutil.Discard, 2048)
if err != nil {
return "", err
}
// Create the repo with the config
cfg.Datastore.StorageMax="1GB"
cfg.Pubsub.Router="gossipsub"
cfg.Pubsub.Enabled=1
cfg.Ipns.UsePubsub=1
err = fsrepo.Init(repoPath, cfg)
if err != nil {
return "", fmt.Errorf("failed to init ephemeral node: %s", err)
}
But it is impossible to use. Code like
func topic_sub(ctx context.Context, chnl chan string, ipfs icore.CoreAPI, topic string) {
subscription, err := ipfs.PubSub().Subscribe(ctx, topic)
returns “Error! Failed topic subscribtion in topic_subexperimental pubsub feature not enabled. Run daemon with --enable-pubsub-experiment to use.” And it points out that pubsub is not enabled actually.
Any ideas how to make it work?