Example #1
0
// Creates an ipfs node that listens on the given multiaddr and bootstraps to
// the peer in 'bootstrap'
func nodeFromConfig(ctx context.Context, cfg *config.Config) *core.IpfsNode {
	if !logquiet {
		fmt.Printf("Creating node with id: '%s'\n", cfg.Identity.PeerID)
	}

	node, err := core.NewIPFSNode(ctx, core.Online(cfg))
	if err != nil {
		panic(err)
	}

	return node
}
func (p *IPFSHandler) Init(repo string) {
	p.repo = fsrepo.At(repo)
	err := p.repo.Open()
	if err != nil {
		panic(err)
	}

	p.node, err = core.NewIPFSNode(context.Background(), core.Online(p.repo))
	if err != nil {
		panic(err)
	}
}