Exemplo n.º 1
0
// 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
}
Exemplo n.º 2
0
// 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
}
Exemplo n.º 3
0
func add(n *core.IpfsNode, reader io.Reader) (*merkledag.Node, error) {
	mp := n.Pinning.GetManual()

	return importer.BuildDagFromReader(
		n.DAG,
		chunk.DefaultSplitter(reader),
		importer.PinIndirectCB(mp),
	)
}
Exemplo n.º 4
0
func add(n *core.IpfsNode, reader io.Reader) (*merkledag.Node, error) {
	mp := n.Pinning.GetManual()

	node, err := importer.BuildDagFromReader(
		reader,
		n.DAG,
		chunk.DefaultSplitter,
		importer.PinIndirectCB(mp),
	)
	if err != nil {
		return nil, err
	}

	return node, nil
}