本文整理汇总了Golang中github.com/ipfs/go-ipfs/importer.BuildTrickleDagFromReader函数的典型用法代码示例。如果您正苦于以下问题:Golang BuildTrickleDagFromReader函数的具体用法?Golang BuildTrickleDagFromReader怎么用?Golang BuildTrickleDagFromReader使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了BuildTrickleDagFromReader函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: add
// Perform the actual add & pin locally, outputting results to reader
func add(n *core.IpfsNode, reader io.Reader, useTrickle bool, chunker string) (*dag.Node, error) {
chnk, err := chunk.FromString(reader, chunker)
if err != nil {
return nil, err
}
var node *dag.Node
if useTrickle {
node, err = importer.BuildTrickleDagFromReader(
n.DAG,
chnk,
importer.PinIndirectCB(n.Pinning.GetManual()),
)
} else {
node, err = importer.BuildDagFromReader(
n.DAG,
chnk,
importer.PinIndirectCB(n.Pinning.GetManual()),
)
}
if err != nil {
return nil, err
}
return node, nil
}
示例2: add
// Perform the actual add & pin locally, outputting results to reader
func add(n *core.IpfsNode, reader io.Reader, useTrickle bool) (*dag.Node, error) {
var node *dag.Node
var err error
if useTrickle {
node, err = importer.BuildTrickleDagFromReader(
reader,
n.DAG,
chunk.DefaultSplitter,
importer.PinIndirectCB(n.Pinning.GetManual()),
)
} else {
node, err = importer.BuildDagFromReader(
reader,
n.DAG,
chunk.DefaultSplitter,
importer.PinIndirectCB(n.Pinning.GetManual()),
)
}
if err != nil {
return nil, err
}
return node, nil
}
示例3: GetNode
func GetNode(t testing.TB, dserv mdag.DAGService, data []byte) node.Node {
in := bytes.NewReader(data)
node, err := imp.BuildTrickleDagFromReader(dserv, SizeSplitterGen(500)(in))
if err != nil {
t.Fatal(err)
}
return node
}
示例4: randObj
func randObj(t *testing.T, nd *core.IpfsNode, size int64) (*dag.Node, []byte) {
buf := make([]byte, size)
u.NewTimeSeededRand().Read(buf)
read := bytes.NewReader(buf)
obj, err := importer.BuildTrickleDagFromReader(nd.DAG, chunk.DefaultSplitter(read))
if err != nil {
t.Fatal(err)
}
return obj, buf
}
示例5: add
// Perform the actual add & pin locally, outputting results to reader
func (adder Adder) add(reader io.Reader) (*dag.Node, error) {
chnk, err := chunk.FromString(reader, adder.Chunker)
if err != nil {
return nil, err
}
if adder.Trickle {
return importer.BuildTrickleDagFromReader(
adder.node.DAG,
chnk,
)
}
return importer.BuildDagFromReader(
adder.node.DAG,
chnk,
)
}
示例6: getNode
func getNode(t testing.TB, dserv mdag.DAGService, size int64) ([]byte, *mdag.Node) {
in := io.LimitReader(u.NewTimeSeededRand(), size)
node, err := imp.BuildTrickleDagFromReader(dserv, sizeSplitterGen(500)(in))
if err != nil {
t.Fatal(err)
}
dr, err := uio.NewDagReader(context.Background(), node, dserv)
if err != nil {
t.Fatal(err)
}
b, err := ioutil.ReadAll(dr)
if err != nil {
t.Fatal(err)
}
return b, node
}
示例7: getNode
func getNode(t testing.TB, dserv mdag.DAGService, size int64, pinner pin.ManualPinner) ([]byte, *mdag.Node) {
in := io.LimitReader(u.NewTimeSeededRand(), size)
node, err := imp.BuildTrickleDagFromReader(in, dserv, &chunk.SizeSplitter{500}, imp.BasicPinnerCB(pinner))
if err != nil {
t.Fatal(err)
}
dr, err := uio.NewDagReader(context.Background(), node, dserv)
if err != nil {
t.Fatal(err)
}
b, err := ioutil.ReadAll(dr)
if err != nil {
t.Fatal(err)
}
return b, node
}