Skip to content

Commit

Permalink
misc: Remove some dead code
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Łukasz Magiera <[email protected]>
  • Loading branch information
magik6k committed Mar 19, 2018
1 parent 958483f commit 8dd552c
Show file tree
Hide file tree
Showing 20 changed files with 22 additions and 219 deletions.
39 changes: 2 additions & 37 deletions cmd/ipfs/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import (
"fmt"
"io"
"math/rand"
"net"
"net/url"
"os"
"os/signal"
"path/filepath"
Expand Down Expand Up @@ -49,18 +47,6 @@ const (
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:
// - parse the commandline to get a cmdInvocation
// - if user requests help, print it and exit.
Expand Down Expand Up @@ -171,7 +157,7 @@ func makeExecutor(req *cmds.Request, env interface{}) (cmds.Executor, error) {
return nil, err
}

client, err := commandShouldRunOnDaemon(*details, req, Root, env.(*oldcmds.Context))
client, err := commandShouldRunOnDaemon(*details, req, env.(*oldcmds.Context))
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -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 should be executed on a client. It returns an error if the command must
// 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
// root command.
if len(path) < 1 {
Expand Down Expand Up @@ -478,24 +464,3 @@ func apiClientForAddr(addr ma.Multiaddr) (http.Client, error) {

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
}
55 changes: 0 additions & 55 deletions commands/legacy/responseemitter.go

This file was deleted.

3 changes: 0 additions & 3 deletions core/commands/dag/dag.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,13 @@ import (
path "github.com/ipfs/go-ipfs/path"
pin "github.com/ipfs/go-ipfs/pin"

logging "gx/ipfs/QmRb5jh8z2E8hMGN2tkvs1yHynUanqnZ3UeKwgN1i9P1F8/go-log"
mh "gx/ipfs/QmZyZDi491cCNTLfAhwcaDii2Kg4pwKRkhqQzURGDvY6ua/go-multihash"
cid "gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid"
cmdkit "gx/ipfs/QmceUdzxkimdYsgtX733uNgzf1DLHyBKN6ehGSp85ayppM/go-ipfs-cmdkit"
files "gx/ipfs/QmceUdzxkimdYsgtX733uNgzf1DLHyBKN6ehGSp85ayppM/go-ipfs-cmdkit/files"
ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
)

var log = logging.Logger("cmds/files")

var DagCmd = &cmds.Command{
Helptext: cmdkit.HelpText{
Tagline: "Interact with ipld dag objects.",
Expand Down
8 changes: 2 additions & 6 deletions core/commands/filestore.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ import (
e "github.com/ipfs/go-ipfs/core/commands/e"
"github.com/ipfs/go-ipfs/filestore"

lgc "github.com/ipfs/go-ipfs/commands/legacy"
cmds "gx/ipfs/QmabLouZTZwhfALuBcssPvkzhbYGMb4394huT7HY4LQ6d3/go-ipfs-cmds"
cid "gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid"
"gx/ipfs/QmceUdzxkimdYsgtX733uNgzf1DLHyBKN6ehGSp85ayppM/go-ipfs-cmdkit"

lgc "github.com/ipfs/go-ipfs/commands/legacy"
)

var FileStoreCmd = &cmds.Command{
Expand All @@ -28,11 +29,6 @@ var FileStoreCmd = &cmds.Command{
},
}

type lsEncoder struct {
errors bool
w io.Writer
}

var lsFileStore = &cmds.Command{
Helptext: cmdkit.HelpText{
Tagline: "List objects in filestore.",
Expand Down
2 changes: 1 addition & 1 deletion core/commands/object/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ func deserializeNode(nd *Node, dataFieldEncoding string) (*dag.ProtoNode, error)
}

func NodeEmpty(node *Node) bool {
return (node.Data == "" && len(node.Links) == 0)
return node.Data == "" && len(node.Links) == 0
}

// copy+pasted from ../commands.go
Expand Down
3 changes: 0 additions & 3 deletions core/commands/object/patch.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,10 @@ import (
path "github.com/ipfs/go-ipfs/path"
ft "github.com/ipfs/go-ipfs/unixfs"

logging "gx/ipfs/QmRb5jh8z2E8hMGN2tkvs1yHynUanqnZ3UeKwgN1i9P1F8/go-log"
cmds "gx/ipfs/QmabLouZTZwhfALuBcssPvkzhbYGMb4394huT7HY4LQ6d3/go-ipfs-cmds"
cmdkit "gx/ipfs/QmceUdzxkimdYsgtX733uNgzf1DLHyBKN6ehGSp85ayppM/go-ipfs-cmdkit"
)

var log = logging.Logger("core/commands/object")

var ObjectPatchCmd = &cmds.Command{
Helptext: cmdkit.HelpText{
Tagline: "Create a new merkledag object based on an existing one.",
Expand Down
8 changes: 4 additions & 4 deletions core/commands/pin.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,9 +305,9 @@ Example:
var keys map[string]RefKeyObject

if len(req.Arguments()) > 0 {
keys, err = pinLsKeys(req.Arguments(), typeStr, req.Context(), n)
keys, err = pinLsKeys(req.Context(), req.Arguments(), typeStr, n)
} else {
keys, err = pinLsAll(typeStr, req.Context(), n)
keys, err = pinLsAll(typeStr, n)
}

if err != nil {
Expand Down Expand Up @@ -492,7 +492,7 @@ type RefKeyList struct {
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)
if !ok {
Expand Down Expand Up @@ -539,7 +539,7 @@ func pinLsKeys(args []string, typeStr string, ctx context.Context, n *core.IpfsN
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)

Expand Down
7 changes: 3 additions & 4 deletions core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ func (n *IpfsNode) startOnlineServices(ctx context.Context, routingOption Routin
}

// 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
}

Expand Down Expand Up @@ -452,9 +452,8 @@ func (n *IpfsNode) startOnlineServicesWithHost(ctx context.Context, host p2phost
n.PeerHost = rhost.Wrap(host, n.Routing)

// setup exchange service
const alwaysSendToPeer = true // use YesManStrategy
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()
if err != nil {
Expand Down Expand Up @@ -919,7 +918,7 @@ func composeAddrsFactory(f, g p2pbhost.AddrsFactory) p2pbhost.AddrsFactory {
}

// 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)
if err != nil {
return err
Expand Down
28 changes: 0 additions & 28 deletions core/coreunix/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ import (
gopath "path"
"strconv"

bserv "github.com/ipfs/go-ipfs/blockservice"
core "github.com/ipfs/go-ipfs/core"
"github.com/ipfs/go-ipfs/exchange/offline"
balanced "github.com/ipfs/go-ipfs/importer/balanced"
ihelper "github.com/ipfs/go-ipfs/importer/helpers"
trickle "github.com/ipfs/go-ipfs/importer/trickle"
Expand All @@ -20,8 +18,6 @@ import (
"github.com/ipfs/go-ipfs/pin"
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"
bstore "gx/ipfs/QmTVDM4LCSUMFNQzbDLL9zQwp8usE6QHymFdh3h8vL9v6b/go-ipfs-blockstore"
chunker "gx/ipfs/QmWo8jYc19ppG7YoTsrr2kEtLRbARTJho5oNXFTR6B7Peq/go-ipfs-chunker"
Expand Down Expand Up @@ -49,22 +45,6 @@ type Object struct {
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 {
Name string
Hash string `json:",omitempty"`
Expand Down Expand Up @@ -573,14 +553,6 @@ func outputDagnode(out chan interface{}, name string, dn ipld.Node) error {
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
func getOutput(dagnode ipld.Node) (*Object, error) {
c := dagnode.Cid()
Expand Down
4 changes: 2 additions & 2 deletions exchange/bitswap/bitswap.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ var rebroadcastDelay = delay.Fixed(time.Minute)
// BitSwapNetwork. This function registers the returned instance as the network
// delegate.
// Runs until context is cancelled.
func New(parent context.Context, p peer.ID, network bsnet.BitSwapNetwork,
bstore blockstore.Blockstore, nice bool) exchange.Interface {
func New(parent context.Context, network bsnet.BitSwapNetwork,
bstore blockstore.Blockstore) exchange.Interface {

// 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
Expand Down
4 changes: 1 addition & 3 deletions exchange/bitswap/testutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
}

const alwaysSendToPeer = true

bs := New(ctx, p.ID(), adapter, bstore, alwaysSendToPeer).(*Bitswap)
bs := New(ctx, adapter, bstore).(*Bitswap)

return Instance{
Peer: p.ID(),
Expand Down
29 changes: 0 additions & 29 deletions fuse/ipns/writerat.go

This file was deleted.

4 changes: 2 additions & 2 deletions importer/helpers/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (

dag "github.com/ipfs/go-ipfs/merkledag"
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"
ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
)
Expand All @@ -32,7 +32,7 @@ var roughLinkSize = 34 + 8 + 5 // sha256 multihash + size + no name + protobuf
// var DefaultLinksPerBlock = (roughLinkBlockSize / roughLinkSize)
//
// See calc_test.go
var DefaultLinksPerBlock = (roughLinkBlockSize / roughLinkSize)
var DefaultLinksPerBlock = roughLinkBlockSize / roughLinkSize

// ErrSizeLimitExceeded signals that a block is larger than BlockSizeLimit.
var ErrSizeLimitExceeded = fmt.Errorf("object size limit exceeded")
Expand Down
Loading

0 comments on commit 8dd552c

Please sign in to comment.