Beispiel #1
0
Datei: add.go Projekt: rht/ipget
// 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
}
Beispiel #2
0
Datei: add.go Projekt: rht/ipget
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),
	)
}