Skip to content

Commit

Permalink
ipfs: announce uploaded files
Browse files Browse the repository at this point in the history
  • Loading branch information
n8maninger committed Mar 3, 2024
1 parent 4faef71 commit 29f1a7f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion ipfs/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ func NewNode(ctx context.Context, privateKey crypto.PrivKey, cfg config.IPFS, ds
providerOpts := []provider.Option{
provider.KeyProvider(provider.NewBlockstoreProvider(bs)),
provider.Online(frt),
provider.ReproviderInterval(6 * time.Hour),
provider.ReproviderInterval(10 * time.Hour),
}

prov, err := provider.New(ds, providerOpts...)
Expand Down
11 changes: 9 additions & 2 deletions ipfs/unixfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func (n *Node) UploadUnixFile(ctx context.Context, r io.Reader, opts ...UnixFSOp
}

params := ihelpers.DagBuilderParams{
Dagserv: merkledag.NewDAGService(n.blockService),
Dagserv: n.dagService,
CidBuilder: opt.CIDBuilder,
RawLeaves: opt.RawLeaves,
Maxlinks: opt.MaxLinks,
Expand All @@ -117,5 +117,12 @@ func (n *Node) UploadUnixFile(ctx context.Context, r io.Reader, opts ...UnixFSOp
return nil, fmt.Errorf("failed to create dag builder: %w", err)
}

return balanced.Layout(db)
rootNode, err := balanced.Layout(db)
if err != nil {
return nil, fmt.Errorf("failed to create balanced layout: %w", err)
} else if err := n.provider.Provide(rootNode.Cid()); err != nil {
return nil, fmt.Errorf("failed to provide root node: %w", err)
}

return rootNode, nil
}

0 comments on commit 29f1a7f

Please sign in to comment.