mirror of
https://github.com/ipfs/kubo.git
synced 2025-05-20 00:18:12 +08:00
misc: Remove some dead code
License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
This commit is contained in:
@ -7,8 +7,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"net"
|
|
||||||
"net/url"
|
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@ -49,18 +47,6 @@ const (
|
|||||||
heapProfile = "ipfs.memprof"
|
heapProfile = "ipfs.memprof"
|
||||||
)
|
)
|
||||||
|
|
||||||
type cmdInvocation struct {
|
|
||||||
req *cmds.Request
|
|
||||||
node *core.IpfsNode
|
|
||||||
ctx *oldcmds.Context
|
|
||||||
}
|
|
||||||
|
|
||||||
type exitErr int
|
|
||||||
|
|
||||||
func (e exitErr) Error() string {
|
|
||||||
return fmt.Sprint("exit code", int(e))
|
|
||||||
}
|
|
||||||
|
|
||||||
// main roadmap:
|
// main roadmap:
|
||||||
// - parse the commandline to get a cmdInvocation
|
// - parse the commandline to get a cmdInvocation
|
||||||
// - if user requests help, print it and exit.
|
// - if user requests help, print it and exit.
|
||||||
@ -171,7 +157,7 @@ func makeExecutor(req *cmds.Request, env interface{}) (cmds.Executor, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
client, err := commandShouldRunOnDaemon(*details, req, Root, env.(*oldcmds.Context))
|
client, err := commandShouldRunOnDaemon(*details, req, env.(*oldcmds.Context))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -241,7 +227,7 @@ func commandDetails(path []string, root *cmds.Command) (*cmdDetails, error) {
|
|||||||
// It returns a client if the command should be executed on a daemon and nil if
|
// It returns a client if the command should be executed on a daemon and nil if
|
||||||
// it should be executed on a client. It returns an error if the command must
|
// it should be executed on a client. It returns an error if the command must
|
||||||
// NOT be executed on either.
|
// NOT be executed on either.
|
||||||
func commandShouldRunOnDaemon(details cmdDetails, req *cmds.Request, root *cmds.Command, cctx *oldcmds.Context) (http.Client, error) {
|
func commandShouldRunOnDaemon(details cmdDetails, req *cmds.Request, cctx *oldcmds.Context) (http.Client, error) {
|
||||||
path := req.Path
|
path := req.Path
|
||||||
// root command.
|
// root command.
|
||||||
if len(path) < 1 {
|
if len(path) < 1 {
|
||||||
@ -478,24 +464,3 @@ func apiClientForAddr(addr ma.Multiaddr) (http.Client, error) {
|
|||||||
|
|
||||||
return http.NewClient(host, http.ClientWithAPIPrefix(corehttp.APIPath)), nil
|
return http.NewClient(host, http.ClientWithAPIPrefix(corehttp.APIPath)), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func isConnRefused(err error) bool {
|
|
||||||
// unwrap url errors from http calls
|
|
||||||
if urlerr, ok := err.(*url.Error); ok {
|
|
||||||
err = urlerr.Err
|
|
||||||
}
|
|
||||||
|
|
||||||
netoperr, ok := err.(*net.OpError)
|
|
||||||
if !ok {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
return netoperr.Op == "dial"
|
|
||||||
}
|
|
||||||
|
|
||||||
func wrapContextCanceled(err error) error {
|
|
||||||
if strings.Contains(err.Error(), "request canceled") {
|
|
||||||
err = errRequestCanceled
|
|
||||||
}
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
@ -1,55 +0,0 @@
|
|||||||
package legacy
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"io"
|
|
||||||
|
|
||||||
"gx/ipfs/QmceUdzxkimdYsgtX733uNgzf1DLHyBKN6ehGSp85ayppM/go-ipfs-cmdkit"
|
|
||||||
|
|
||||||
oldcmds "github.com/ipfs/go-ipfs/commands"
|
|
||||||
)
|
|
||||||
|
|
||||||
// wrappedResponseEmitter implements a ResponseEmitter by forwarding everything to an oldcmds.Response
|
|
||||||
type wrappedResponseEmitter struct {
|
|
||||||
r oldcmds.Response
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetLength forwards the call to the underlying oldcmds.Response
|
|
||||||
func (re *wrappedResponseEmitter) SetLength(l uint64) {
|
|
||||||
re.r.SetLength(l)
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetError forwards the call to the underlying oldcmds.Response
|
|
||||||
func (re *wrappedResponseEmitter) SetError(err interface{}, code cmdkit.ErrorType) {
|
|
||||||
re.r.SetError(fmt.Errorf("%v", err), code)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Close forwards the call to the underlying oldcmds.Response
|
|
||||||
func (re *wrappedResponseEmitter) Close() error {
|
|
||||||
return re.r.Close()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Emit sends the value to the underlying oldcmds.Response
|
|
||||||
func (re *wrappedResponseEmitter) Emit(v interface{}) error {
|
|
||||||
if re.r.Output() == nil {
|
|
||||||
switch c := v.(type) {
|
|
||||||
case io.Reader:
|
|
||||||
re.r.SetOutput(c)
|
|
||||||
return nil
|
|
||||||
case chan interface{}:
|
|
||||||
re.r.SetOutput(c)
|
|
||||||
return nil
|
|
||||||
case <-chan interface{}:
|
|
||||||
re.r.SetOutput(c)
|
|
||||||
return nil
|
|
||||||
default:
|
|
||||||
re.r.SetOutput(make(chan interface{}))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
go func() {
|
|
||||||
re.r.Output().(chan interface{}) <- v
|
|
||||||
}()
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
@ -13,7 +13,6 @@ import (
|
|||||||
path "github.com/ipfs/go-ipfs/path"
|
path "github.com/ipfs/go-ipfs/path"
|
||||||
pin "github.com/ipfs/go-ipfs/pin"
|
pin "github.com/ipfs/go-ipfs/pin"
|
||||||
|
|
||||||
logging "gx/ipfs/QmRb5jh8z2E8hMGN2tkvs1yHynUanqnZ3UeKwgN1i9P1F8/go-log"
|
|
||||||
mh "gx/ipfs/QmZyZDi491cCNTLfAhwcaDii2Kg4pwKRkhqQzURGDvY6ua/go-multihash"
|
mh "gx/ipfs/QmZyZDi491cCNTLfAhwcaDii2Kg4pwKRkhqQzURGDvY6ua/go-multihash"
|
||||||
cid "gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid"
|
cid "gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid"
|
||||||
cmdkit "gx/ipfs/QmceUdzxkimdYsgtX733uNgzf1DLHyBKN6ehGSp85ayppM/go-ipfs-cmdkit"
|
cmdkit "gx/ipfs/QmceUdzxkimdYsgtX733uNgzf1DLHyBKN6ehGSp85ayppM/go-ipfs-cmdkit"
|
||||||
@ -21,8 +20,6 @@ import (
|
|||||||
ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
|
ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
|
||||||
)
|
)
|
||||||
|
|
||||||
var log = logging.Logger("cmds/files")
|
|
||||||
|
|
||||||
var DagCmd = &cmds.Command{
|
var DagCmd = &cmds.Command{
|
||||||
Helptext: cmdkit.HelpText{
|
Helptext: cmdkit.HelpText{
|
||||||
Tagline: "Interact with ipld dag objects.",
|
Tagline: "Interact with ipld dag objects.",
|
||||||
|
@ -7,11 +7,11 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
|
|
||||||
oldCmds "github.com/ipfs/go-ipfs/commands"
|
oldCmds "github.com/ipfs/go-ipfs/commands"
|
||||||
|
lgc "github.com/ipfs/go-ipfs/commands/legacy"
|
||||||
"github.com/ipfs/go-ipfs/core"
|
"github.com/ipfs/go-ipfs/core"
|
||||||
e "github.com/ipfs/go-ipfs/core/commands/e"
|
e "github.com/ipfs/go-ipfs/core/commands/e"
|
||||||
"github.com/ipfs/go-ipfs/filestore"
|
"github.com/ipfs/go-ipfs/filestore"
|
||||||
|
|
||||||
lgc "github.com/ipfs/go-ipfs/commands/legacy"
|
|
||||||
cid "gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid"
|
cid "gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid"
|
||||||
"gx/ipfs/QmceUdzxkimdYsgtX733uNgzf1DLHyBKN6ehGSp85ayppM/go-ipfs-cmdkit"
|
"gx/ipfs/QmceUdzxkimdYsgtX733uNgzf1DLHyBKN6ehGSp85ayppM/go-ipfs-cmdkit"
|
||||||
cmds "gx/ipfs/QmfAkMSt9Fwzk48QDJecPcwCUjnf2uG7MLnmCGTp4C6ouL/go-ipfs-cmds"
|
cmds "gx/ipfs/QmfAkMSt9Fwzk48QDJecPcwCUjnf2uG7MLnmCGTp4C6ouL/go-ipfs-cmds"
|
||||||
@ -28,11 +28,6 @@ var FileStoreCmd = &cmds.Command{
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
type lsEncoder struct {
|
|
||||||
errors bool
|
|
||||||
w io.Writer
|
|
||||||
}
|
|
||||||
|
|
||||||
var lsFileStore = &cmds.Command{
|
var lsFileStore = &cmds.Command{
|
||||||
Helptext: cmdkit.HelpText{
|
Helptext: cmdkit.HelpText{
|
||||||
Tagline: "List objects in filestore.",
|
Tagline: "List objects in filestore.",
|
||||||
|
@ -686,7 +686,7 @@ func deserializeNode(nd *Node, dataFieldEncoding string) (*dag.ProtoNode, error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NodeEmpty(node *Node) bool {
|
func NodeEmpty(node *Node) bool {
|
||||||
return (node.Data == "" && len(node.Links) == 0)
|
return node.Data == "" && len(node.Links) == 0
|
||||||
}
|
}
|
||||||
|
|
||||||
// copy+pasted from ../commands.go
|
// copy+pasted from ../commands.go
|
||||||
|
@ -305,9 +305,9 @@ Example:
|
|||||||
var keys map[string]RefKeyObject
|
var keys map[string]RefKeyObject
|
||||||
|
|
||||||
if len(req.Arguments()) > 0 {
|
if len(req.Arguments()) > 0 {
|
||||||
keys, err = pinLsKeys(req.Arguments(), typeStr, req.Context(), n)
|
keys, err = pinLsKeys(req.Context(), req.Arguments(), typeStr, n)
|
||||||
} else {
|
} else {
|
||||||
keys, err = pinLsAll(typeStr, req.Context(), n)
|
keys, err = pinLsAll(typeStr, n)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -492,7 +492,7 @@ type RefKeyList struct {
|
|||||||
Keys map[string]RefKeyObject
|
Keys map[string]RefKeyObject
|
||||||
}
|
}
|
||||||
|
|
||||||
func pinLsKeys(args []string, typeStr string, ctx context.Context, n *core.IpfsNode) (map[string]RefKeyObject, error) {
|
func pinLsKeys(ctx context.Context, args []string, typeStr string, n *core.IpfsNode) (map[string]RefKeyObject, error) {
|
||||||
|
|
||||||
mode, ok := pin.StringToMode(typeStr)
|
mode, ok := pin.StringToMode(typeStr)
|
||||||
if !ok {
|
if !ok {
|
||||||
@ -539,7 +539,7 @@ func pinLsKeys(args []string, typeStr string, ctx context.Context, n *core.IpfsN
|
|||||||
return keys, nil
|
return keys, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func pinLsAll(typeStr string, ctx context.Context, n *core.IpfsNode) (map[string]RefKeyObject, error) {
|
func pinLsAll(typeStr string, n *core.IpfsNode) (map[string]RefKeyObject, error) {
|
||||||
|
|
||||||
keys := make(map[string]RefKeyObject)
|
keys := make(map[string]RefKeyObject)
|
||||||
|
|
||||||
|
@ -245,7 +245,7 @@ func (n *IpfsNode) startOnlineServices(ctx context.Context, routingOption Routin
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Ok, now we're ready to listen.
|
// Ok, now we're ready to listen.
|
||||||
if err := startListening(ctx, n.PeerHost, cfg); err != nil {
|
if err := startListening(n.PeerHost, cfg); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -452,9 +452,8 @@ func (n *IpfsNode) startOnlineServicesWithHost(ctx context.Context, host p2phost
|
|||||||
n.PeerHost = rhost.Wrap(host, n.Routing)
|
n.PeerHost = rhost.Wrap(host, n.Routing)
|
||||||
|
|
||||||
// setup exchange service
|
// setup exchange service
|
||||||
const alwaysSendToPeer = true // use YesManStrategy
|
|
||||||
bitswapNetwork := bsnet.NewFromIpfsHost(n.PeerHost, n.Routing)
|
bitswapNetwork := bsnet.NewFromIpfsHost(n.PeerHost, n.Routing)
|
||||||
n.Exchange = bitswap.New(ctx, n.Identity, bitswapNetwork, n.Blockstore, alwaysSendToPeer)
|
n.Exchange = bitswap.New(ctx, bitswapNetwork, n.Blockstore)
|
||||||
|
|
||||||
size, err := n.getCacheSize()
|
size, err := n.getCacheSize()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -919,7 +918,7 @@ func composeAddrsFactory(f, g p2pbhost.AddrsFactory) p2pbhost.AddrsFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// startListening on the network addresses
|
// startListening on the network addresses
|
||||||
func startListening(ctx context.Context, host p2phost.Host, cfg *config.Config) error {
|
func startListening(host p2phost.Host, cfg *config.Config) error {
|
||||||
listenAddrs, err := listenAddresses(cfg)
|
listenAddrs, err := listenAddresses(cfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -9,9 +9,7 @@ import (
|
|||||||
gopath "path"
|
gopath "path"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
bserv "github.com/ipfs/go-ipfs/blockservice"
|
|
||||||
core "github.com/ipfs/go-ipfs/core"
|
core "github.com/ipfs/go-ipfs/core"
|
||||||
"github.com/ipfs/go-ipfs/exchange/offline"
|
|
||||||
balanced "github.com/ipfs/go-ipfs/importer/balanced"
|
balanced "github.com/ipfs/go-ipfs/importer/balanced"
|
||||||
ihelper "github.com/ipfs/go-ipfs/importer/helpers"
|
ihelper "github.com/ipfs/go-ipfs/importer/helpers"
|
||||||
trickle "github.com/ipfs/go-ipfs/importer/trickle"
|
trickle "github.com/ipfs/go-ipfs/importer/trickle"
|
||||||
@ -20,8 +18,6 @@ import (
|
|||||||
"github.com/ipfs/go-ipfs/pin"
|
"github.com/ipfs/go-ipfs/pin"
|
||||||
unixfs "github.com/ipfs/go-ipfs/unixfs"
|
unixfs "github.com/ipfs/go-ipfs/unixfs"
|
||||||
|
|
||||||
ds "gx/ipfs/QmPpegoMqhAEqjncrzArm7KVWAkCm78rqL2DPuNjhPrshg/go-datastore"
|
|
||||||
syncds "gx/ipfs/QmPpegoMqhAEqjncrzArm7KVWAkCm78rqL2DPuNjhPrshg/go-datastore/sync"
|
|
||||||
logging "gx/ipfs/QmRb5jh8z2E8hMGN2tkvs1yHynUanqnZ3UeKwgN1i9P1F8/go-log"
|
logging "gx/ipfs/QmRb5jh8z2E8hMGN2tkvs1yHynUanqnZ3UeKwgN1i9P1F8/go-log"
|
||||||
bstore "gx/ipfs/QmTVDM4LCSUMFNQzbDLL9zQwp8usE6QHymFdh3h8vL9v6b/go-ipfs-blockstore"
|
bstore "gx/ipfs/QmTVDM4LCSUMFNQzbDLL9zQwp8usE6QHymFdh3h8vL9v6b/go-ipfs-blockstore"
|
||||||
chunker "gx/ipfs/QmWo8jYc19ppG7YoTsrr2kEtLRbARTJho5oNXFTR6B7Peq/go-ipfs-chunker"
|
chunker "gx/ipfs/QmWo8jYc19ppG7YoTsrr2kEtLRbARTJho5oNXFTR6B7Peq/go-ipfs-chunker"
|
||||||
@ -49,22 +45,6 @@ type Object struct {
|
|||||||
Size string
|
Size string
|
||||||
}
|
}
|
||||||
|
|
||||||
type hiddenFileError struct {
|
|
||||||
fileName string
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e *hiddenFileError) Error() string {
|
|
||||||
return fmt.Sprintf("%s is a hidden file", e.fileName)
|
|
||||||
}
|
|
||||||
|
|
||||||
type ignoreFileError struct {
|
|
||||||
fileName string
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e *ignoreFileError) Error() string {
|
|
||||||
return fmt.Sprintf("%s is an ignored file", e.fileName)
|
|
||||||
}
|
|
||||||
|
|
||||||
type AddedObject struct {
|
type AddedObject struct {
|
||||||
Name string
|
Name string
|
||||||
Hash string `json:",omitempty"`
|
Hash string `json:",omitempty"`
|
||||||
@ -573,14 +553,6 @@ func outputDagnode(out chan interface{}, name string, dn ipld.Node) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewMemoryDagService builds and returns a new mem-datastore.
|
|
||||||
func NewMemoryDagService() ipld.DAGService {
|
|
||||||
// build mem-datastore for editor's intermediary nodes
|
|
||||||
bs := bstore.NewBlockstore(syncds.MutexWrap(ds.NewMapDatastore()))
|
|
||||||
bsrv := bserv.New(bs, offline.Exchange(bs))
|
|
||||||
return dag.NewDAGService(bsrv)
|
|
||||||
}
|
|
||||||
|
|
||||||
// from core/commands/object.go
|
// from core/commands/object.go
|
||||||
func getOutput(dagnode ipld.Node) (*Object, error) {
|
func getOutput(dagnode ipld.Node) (*Object, error) {
|
||||||
c := dagnode.Cid()
|
c := dagnode.Cid()
|
||||||
|
@ -66,8 +66,8 @@ var rebroadcastDelay = delay.Fixed(time.Minute)
|
|||||||
// BitSwapNetwork. This function registers the returned instance as the network
|
// BitSwapNetwork. This function registers the returned instance as the network
|
||||||
// delegate.
|
// delegate.
|
||||||
// Runs until context is cancelled.
|
// Runs until context is cancelled.
|
||||||
func New(parent context.Context, p peer.ID, network bsnet.BitSwapNetwork,
|
func New(parent context.Context, network bsnet.BitSwapNetwork,
|
||||||
bstore blockstore.Blockstore, nice bool) exchange.Interface {
|
bstore blockstore.Blockstore) exchange.Interface {
|
||||||
|
|
||||||
// important to use provided parent context (since it may include important
|
// important to use provided parent context (since it may include important
|
||||||
// loggable data). It's probably not a good idea to allow bitswap to be
|
// loggable data). It's probably not a good idea to allow bitswap to be
|
||||||
|
@ -99,9 +99,7 @@ func MkSession(ctx context.Context, net tn.Network, p testutil.Identity) Instanc
|
|||||||
panic(err.Error()) // FIXME perhaps change signature and return error.
|
panic(err.Error()) // FIXME perhaps change signature and return error.
|
||||||
}
|
}
|
||||||
|
|
||||||
const alwaysSendToPeer = true
|
bs := New(ctx, adapter, bstore).(*Bitswap)
|
||||||
|
|
||||||
bs := New(ctx, p.ID(), adapter, bstore, alwaysSendToPeer).(*Bitswap)
|
|
||||||
|
|
||||||
return Instance{
|
return Instance{
|
||||||
Peer: p.ID(),
|
Peer: p.ID(),
|
||||||
|
@ -1,29 +0,0 @@
|
|||||||
package ipns
|
|
||||||
|
|
||||||
import "io"
|
|
||||||
|
|
||||||
type WriteAtBuf interface {
|
|
||||||
io.WriterAt
|
|
||||||
Bytes() []byte
|
|
||||||
}
|
|
||||||
|
|
||||||
type writerAt struct {
|
|
||||||
buf []byte
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewWriterAtFromBytes(b []byte) WriteAtBuf {
|
|
||||||
return &writerAt{b}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: make this better in the future, this is just a quick hack for now
|
|
||||||
func (wa *writerAt) WriteAt(p []byte, off int64) (int, error) {
|
|
||||||
if off+int64(len(p)) > int64(len(wa.buf)) {
|
|
||||||
wa.buf = append(wa.buf, make([]byte, (int(off)+len(p))-len(wa.buf))...)
|
|
||||||
}
|
|
||||||
copy(wa.buf[off:], p)
|
|
||||||
return len(p), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (wa *writerAt) Bytes() []byte {
|
|
||||||
return wa.buf
|
|
||||||
}
|
|
@ -7,8 +7,8 @@ import (
|
|||||||
|
|
||||||
dag "github.com/ipfs/go-ipfs/merkledag"
|
dag "github.com/ipfs/go-ipfs/merkledag"
|
||||||
ft "github.com/ipfs/go-ipfs/unixfs"
|
ft "github.com/ipfs/go-ipfs/unixfs"
|
||||||
pi "gx/ipfs/Qmb3jLEFAQrqdVgWUajqEyuuDoavkSq1XQXz6tWdFWF995/go-ipfs-posinfo"
|
|
||||||
|
|
||||||
|
pi "gx/ipfs/Qmb3jLEFAQrqdVgWUajqEyuuDoavkSq1XQXz6tWdFWF995/go-ipfs-posinfo"
|
||||||
cid "gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid"
|
cid "gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid"
|
||||||
ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
|
ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
|
||||||
)
|
)
|
||||||
@ -32,7 +32,7 @@ var roughLinkSize = 34 + 8 + 5 // sha256 multihash + size + no name + protobuf
|
|||||||
// var DefaultLinksPerBlock = (roughLinkBlockSize / roughLinkSize)
|
// var DefaultLinksPerBlock = (roughLinkBlockSize / roughLinkSize)
|
||||||
//
|
//
|
||||||
// See calc_test.go
|
// See calc_test.go
|
||||||
var DefaultLinksPerBlock = (roughLinkBlockSize / roughLinkSize)
|
var DefaultLinksPerBlock = roughLinkBlockSize / roughLinkSize
|
||||||
|
|
||||||
// ErrSizeLimitExceeded signals that a block is larger than BlockSizeLimit.
|
// ErrSizeLimitExceeded signals that a block is larger than BlockSizeLimit.
|
||||||
var ErrSizeLimitExceeded = fmt.Errorf("object size limit exceeded")
|
var ErrSizeLimitExceeded = fmt.Errorf("object size limit exceeded")
|
||||||
|
@ -3,11 +3,7 @@
|
|||||||
package importer
|
package importer
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
chunker "gx/ipfs/QmWo8jYc19ppG7YoTsrr2kEtLRbARTJho5oNXFTR6B7Peq/go-ipfs-chunker"
|
chunker "gx/ipfs/QmWo8jYc19ppG7YoTsrr2kEtLRbARTJho5oNXFTR6B7Peq/go-ipfs-chunker"
|
||||||
"gx/ipfs/QmceUdzxkimdYsgtX733uNgzf1DLHyBKN6ehGSp85ayppM/go-ipfs-cmdkit/files"
|
|
||||||
ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
|
ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
|
||||||
|
|
||||||
bal "github.com/ipfs/go-ipfs/importer/balanced"
|
bal "github.com/ipfs/go-ipfs/importer/balanced"
|
||||||
@ -15,27 +11,6 @@ import (
|
|||||||
trickle "github.com/ipfs/go-ipfs/importer/trickle"
|
trickle "github.com/ipfs/go-ipfs/importer/trickle"
|
||||||
)
|
)
|
||||||
|
|
||||||
// BuildDagFromFile builds a DAG from the given file, writing created blocks to
|
|
||||||
// disk as they are created.
|
|
||||||
func BuildDagFromFile(fpath string, ds ipld.DAGService) (ipld.Node, error) {
|
|
||||||
stat, err := os.Lstat(fpath)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if stat.IsDir() {
|
|
||||||
return nil, fmt.Errorf("`%s` is a directory", fpath)
|
|
||||||
}
|
|
||||||
|
|
||||||
f, err := files.NewSerialFile(fpath, fpath, false, stat)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
defer f.Close()
|
|
||||||
|
|
||||||
return BuildDagFromReader(ds, chunker.DefaultSplitter(f))
|
|
||||||
}
|
|
||||||
|
|
||||||
// BuildDagFromReader creates a DAG given a DAGService and a Splitter
|
// BuildDagFromReader creates a DAG given a DAGService and a Splitter
|
||||||
// implementation (Splitters are io.Readers), using a Balanced layout.
|
// implementation (Splitters are io.Readers), using a Balanced layout.
|
||||||
func BuildDagFromReader(ds ipld.DAGService, spl chunker.Splitter) (ipld.Node, error) {
|
func BuildDagFromReader(ds ipld.DAGService, spl chunker.Splitter) (ipld.Node, error) {
|
||||||
|
@ -180,18 +180,6 @@ func FetchGraph(ctx context.Context, root *cid.Cid, serv ipld.DAGService) error
|
|||||||
return EnumerateChildrenAsync(ctx, GetLinksDirect(ng), root, visit)
|
return EnumerateChildrenAsync(ctx, GetLinksDirect(ng), root, visit)
|
||||||
}
|
}
|
||||||
|
|
||||||
// FindLinks searches this nodes links for the given key,
|
|
||||||
// returns the indexes of any links pointing to it
|
|
||||||
func FindLinks(links []*cid.Cid, c *cid.Cid, start int) []int {
|
|
||||||
var out []int
|
|
||||||
for i, lnkC := range links[start:] {
|
|
||||||
if c.Equals(lnkC) {
|
|
||||||
out = append(out, i+start)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return out
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetMany gets many nodes from the DAG at once.
|
// GetMany gets many nodes from the DAG at once.
|
||||||
//
|
//
|
||||||
// This method may not return all requested nodes (and may or may not return an
|
// This method may not return all requested nodes (and may or may not return an
|
||||||
|
@ -62,7 +62,7 @@ func (p Path) String() string {
|
|||||||
// IsJustAKey returns true if the path is of the form <key> or /ipfs/<key>.
|
// IsJustAKey returns true if the path is of the form <key> or /ipfs/<key>.
|
||||||
func (p Path) IsJustAKey() bool {
|
func (p Path) IsJustAKey() bool {
|
||||||
parts := p.Segments()
|
parts := p.Segments()
|
||||||
return (len(parts) == 2 && parts[0] == "ipfs")
|
return len(parts) == 2 && parts[0] == "ipfs"
|
||||||
}
|
}
|
||||||
|
|
||||||
// PopLastSegment returns a new Path without its final segment, and the final
|
// PopLastSegment returns a new Path without its final segment, and the final
|
||||||
|
@ -22,7 +22,7 @@ func TestPathParsing(t *testing.T) {
|
|||||||
|
|
||||||
for p, expected := range cases {
|
for p, expected := range cases {
|
||||||
_, err := ParsePath(p)
|
_, err := ParsePath(p)
|
||||||
valid := (err == nil)
|
valid := err == nil
|
||||||
if valid != expected {
|
if valid != expected {
|
||||||
t.Fatalf("expected %s to have valid == %t", p, expected)
|
t.Fatalf("expected %s to have valid == %t", p, expected)
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
when := make(chan (time.Time), 2)
|
when := make(chan time.Time, 2)
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
wg.Add(2)
|
wg.Add(2)
|
||||||
for _, port := range []string{"5001", "8080"} {
|
for _, port := range []string{"5001", "8080"} {
|
||||||
|
@ -81,7 +81,7 @@ func DagArchive(ctx context.Context, nd ipld.Node, name string, dag ipld.DAGServ
|
|||||||
// the case for 1. archive, and 2. not archived and not compressed, in which tar is used anyway as a transport format
|
// the case for 1. archive, and 2. not archived and not compressed, in which tar is used anyway as a transport format
|
||||||
|
|
||||||
// construct the tar writer
|
// construct the tar writer
|
||||||
w, err := tar.NewWriter(ctx, dag, archive, compression, maybeGzw)
|
w, err := tar.NewWriter(ctx, dag, maybeGzw)
|
||||||
if checkErrAndClosePipe(err) {
|
if checkErrAndClosePipe(err) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ type Writer struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewWriter wraps given io.Writer.
|
// NewWriter wraps given io.Writer.
|
||||||
func NewWriter(ctx context.Context, dag ipld.DAGService, archive bool, compression int, w io.Writer) (*Writer, error) {
|
func NewWriter(ctx context.Context, dag ipld.DAGService, w io.Writer) (*Writer, error) {
|
||||||
return &Writer{
|
return &Writer{
|
||||||
Dag: dag,
|
Dag: dag,
|
||||||
TarW: tar.NewWriter(w),
|
TarW: tar.NewWriter(w),
|
||||||
|
Reference in New Issue
Block a user