mirror of
https://github.com/ipfs/kubo.git
synced 2026-03-04 07:48:00 +08:00
Updates: * go-kad-dht: Query performance improvements, DHT client fixes, validates records on *local* put. * go-libp2p-swarm/go-libp2p-transport: Timeout improvements. * go-multiaddr-net: Exposes useful Conn methods (CloseWrite, CloseRead, etc.) * go-log: fixes possible panic when enabling/disabling events. * go-multiaddr: fixes possible panic when stringifying malformed multiaddrs, adds support for consuming /p2p/ multiaddrs. fixes #5113 unblocks #4895 License: MIT Signed-off-by: Steven Allen <steven@stebalien.com>
35 lines
1.1 KiB
Go
35 lines
1.1 KiB
Go
// Package importer implements utilities used to create IPFS DAGs from files
|
|
// and readers.
|
|
package importer
|
|
|
|
import (
|
|
ipld "gx/ipfs/QmWi2BYBL5gJ3CiAiQchg6rn1A8iBsrWy51EYxvHVjFvLb/go-ipld-format"
|
|
chunker "gx/ipfs/QmXnzH7wowyLZy8XJxxaQCVTgLMcDXdMBznmsrmQWCyiQV/go-ipfs-chunker"
|
|
|
|
bal "github.com/ipfs/go-ipfs/importer/balanced"
|
|
h "github.com/ipfs/go-ipfs/importer/helpers"
|
|
trickle "github.com/ipfs/go-ipfs/importer/trickle"
|
|
)
|
|
|
|
// BuildDagFromReader creates a DAG given a DAGService and a Splitter
|
|
// implementation (Splitters are io.Readers), using a Balanced layout.
|
|
func BuildDagFromReader(ds ipld.DAGService, spl chunker.Splitter) (ipld.Node, error) {
|
|
dbp := h.DagBuilderParams{
|
|
Dagserv: ds,
|
|
Maxlinks: h.DefaultLinksPerBlock,
|
|
}
|
|
|
|
return bal.Layout(dbp.New(spl))
|
|
}
|
|
|
|
// BuildTrickleDagFromReader creates a DAG given a DAGService and a Splitter
|
|
// implementation (Splitters are io.Readers), using a Trickle Layout.
|
|
func BuildTrickleDagFromReader(ds ipld.DAGService, spl chunker.Splitter) (ipld.Node, error) {
|
|
dbp := h.DagBuilderParams{
|
|
Dagserv: ds,
|
|
Maxlinks: h.DefaultLinksPerBlock,
|
|
}
|
|
|
|
return trickle.Layout(dbp.New(spl))
|
|
}
|