Skip to content

Commit 0c83696

Browse files
committed
misc: Remove some dead code
License: MIT Signed-off-by: Łukasz Magiera <[email protected]>
1 parent 4bdbe1a commit 0c83696

File tree

20 files changed

+21
-219
lines changed

20 files changed

+21
-219
lines changed

cmd/ipfs/main.go

+2-37
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ import (
77
"fmt"
88
"io"
99
"math/rand"
10-
"net"
11-
"net/url"
1210
"os"
1311
"os/signal"
1412
"path/filepath"
@@ -49,18 +47,6 @@ const (
4947
heapProfile = "ipfs.memprof"
5048
)
5149

52-
type cmdInvocation struct {
53-
req *cmds.Request
54-
node *core.IpfsNode
55-
ctx *oldcmds.Context
56-
}
57-
58-
type exitErr int
59-
60-
func (e exitErr) Error() string {
61-
return fmt.Sprint("exit code", int(e))
62-
}
63-
6450
// main roadmap:
6551
// - parse the commandline to get a cmdInvocation
6652
// - if user requests help, print it and exit.
@@ -171,7 +157,7 @@ func makeExecutor(req *cmds.Request, env interface{}) (cmds.Executor, error) {
171157
return nil, err
172158
}
173159

174-
client, err := commandShouldRunOnDaemon(*details, req, Root, env.(*oldcmds.Context))
160+
client, err := commandShouldRunOnDaemon(*details, req, env.(*oldcmds.Context))
175161
if err != nil {
176162
return nil, err
177163
}
@@ -241,7 +227,7 @@ func commandDetails(path []string, root *cmds.Command) (*cmdDetails, error) {
241227
// It returns a client if the command should be executed on a daemon and nil if
242228
// it should be executed on a client. It returns an error if the command must
243229
// NOT be executed on either.
244-
func commandShouldRunOnDaemon(details cmdDetails, req *cmds.Request, root *cmds.Command, cctx *oldcmds.Context) (http.Client, error) {
230+
func commandShouldRunOnDaemon(details cmdDetails, req *cmds.Request, cctx *oldcmds.Context) (http.Client, error) {
245231
path := req.Path
246232
// root command.
247233
if len(path) < 1 {
@@ -478,24 +464,3 @@ func apiClientForAddr(addr ma.Multiaddr) (http.Client, error) {
478464

479465
return http.NewClient(host, http.ClientWithAPIPrefix(corehttp.APIPath)), nil
480466
}
481-
482-
func isConnRefused(err error) bool {
483-
// unwrap url errors from http calls
484-
if urlerr, ok := err.(*url.Error); ok {
485-
err = urlerr.Err
486-
}
487-
488-
netoperr, ok := err.(*net.OpError)
489-
if !ok {
490-
return false
491-
}
492-
493-
return netoperr.Op == "dial"
494-
}
495-
496-
func wrapContextCanceled(err error) error {
497-
if strings.Contains(err.Error(), "request canceled") {
498-
err = errRequestCanceled
499-
}
500-
return err
501-
}

commands/legacy/responseemitter.go

-55
This file was deleted.

core/commands/dag/dag.go

-3
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,13 @@ import (
1313
path "github.com/ipfs/go-ipfs/path"
1414
pin "github.com/ipfs/go-ipfs/pin"
1515

16-
logging "gx/ipfs/QmRb5jh8z2E8hMGN2tkvs1yHynUanqnZ3UeKwgN1i9P1F8/go-log"
1716
mh "gx/ipfs/QmZyZDi491cCNTLfAhwcaDii2Kg4pwKRkhqQzURGDvY6ua/go-multihash"
1817
cid "gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid"
1918
cmdkit "gx/ipfs/QmceUdzxkimdYsgtX733uNgzf1DLHyBKN6ehGSp85ayppM/go-ipfs-cmdkit"
2019
files "gx/ipfs/QmceUdzxkimdYsgtX733uNgzf1DLHyBKN6ehGSp85ayppM/go-ipfs-cmdkit/files"
2120
ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
2221
)
2322

24-
var log = logging.Logger("cmds/files")
25-
2623
var DagCmd = &cmds.Command{
2724
Helptext: cmdkit.HelpText{
2825
Tagline: "Interact with ipld dag objects.",

core/commands/filestore.go

+1-6
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ import (
77
"os"
88

99
oldCmds "github.com/ipfs/go-ipfs/commands"
10+
lgc "github.com/ipfs/go-ipfs/commands/legacy"
1011
"github.com/ipfs/go-ipfs/core"
1112
e "github.com/ipfs/go-ipfs/core/commands/e"
1213
"github.com/ipfs/go-ipfs/filestore"
1314

14-
lgc "github.com/ipfs/go-ipfs/commands/legacy"
1515
cmds "gx/ipfs/QmSBXjZJCTmRSLXzXr4duHKzWfgDX8aJ6XuPXCQZuVU1LP/go-ipfs-cmds"
1616
cid "gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid"
1717
"gx/ipfs/QmceUdzxkimdYsgtX733uNgzf1DLHyBKN6ehGSp85ayppM/go-ipfs-cmdkit"
@@ -28,11 +28,6 @@ var FileStoreCmd = &cmds.Command{
2828
},
2929
}
3030

31-
type lsEncoder struct {
32-
errors bool
33-
w io.Writer
34-
}
35-
3631
var lsFileStore = &cmds.Command{
3732
Helptext: cmdkit.HelpText{
3833
Tagline: "List objects in filestore.",

core/commands/object/object.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,7 @@ func deserializeNode(nd *Node, dataFieldEncoding string) (*dag.ProtoNode, error)
686686
}
687687

688688
func NodeEmpty(node *Node) bool {
689-
return (node.Data == "" && len(node.Links) == 0)
689+
return node.Data == "" && len(node.Links) == 0
690690
}
691691

692692
// copy+pasted from ../commands.go

core/commands/object/patch.go

-3
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,10 @@ import (
1515
path "github.com/ipfs/go-ipfs/path"
1616
ft "github.com/ipfs/go-ipfs/unixfs"
1717

18-
logging "gx/ipfs/QmRb5jh8z2E8hMGN2tkvs1yHynUanqnZ3UeKwgN1i9P1F8/go-log"
1918
cmds "gx/ipfs/QmSBXjZJCTmRSLXzXr4duHKzWfgDX8aJ6XuPXCQZuVU1LP/go-ipfs-cmds"
2019
cmdkit "gx/ipfs/QmceUdzxkimdYsgtX733uNgzf1DLHyBKN6ehGSp85ayppM/go-ipfs-cmdkit"
2120
)
2221

23-
var log = logging.Logger("core/commands/object")
24-
2522
var ObjectPatchCmd = &cmds.Command{
2623
Helptext: cmdkit.HelpText{
2724
Tagline: "Create a new merkledag object based on an existing one.",

core/commands/pin.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -305,9 +305,9 @@ Example:
305305
var keys map[string]RefKeyObject
306306

307307
if len(req.Arguments()) > 0 {
308-
keys, err = pinLsKeys(req.Arguments(), typeStr, req.Context(), n)
308+
keys, err = pinLsKeys(req.Context(), req.Arguments(), typeStr, n)
309309
} else {
310-
keys, err = pinLsAll(typeStr, req.Context(), n)
310+
keys, err = pinLsAll(typeStr, n)
311311
}
312312

313313
if err != nil {
@@ -492,7 +492,7 @@ type RefKeyList struct {
492492
Keys map[string]RefKeyObject
493493
}
494494

495-
func pinLsKeys(args []string, typeStr string, ctx context.Context, n *core.IpfsNode) (map[string]RefKeyObject, error) {
495+
func pinLsKeys(ctx context.Context, args []string, typeStr string, n *core.IpfsNode) (map[string]RefKeyObject, error) {
496496

497497
mode, ok := pin.StringToMode(typeStr)
498498
if !ok {
@@ -539,7 +539,7 @@ func pinLsKeys(args []string, typeStr string, ctx context.Context, n *core.IpfsN
539539
return keys, nil
540540
}
541541

542-
func pinLsAll(typeStr string, ctx context.Context, n *core.IpfsNode) (map[string]RefKeyObject, error) {
542+
func pinLsAll(typeStr string, n *core.IpfsNode) (map[string]RefKeyObject, error) {
543543

544544
keys := make(map[string]RefKeyObject)
545545

core/core.go

+3-4
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ func (n *IpfsNode) startOnlineServices(ctx context.Context, routingOption Routin
245245
}
246246

247247
// Ok, now we're ready to listen.
248-
if err := startListening(ctx, n.PeerHost, cfg); err != nil {
248+
if err := startListening(n.PeerHost, cfg); err != nil {
249249
return err
250250
}
251251

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

454454
// setup exchange service
455-
const alwaysSendToPeer = true // use YesManStrategy
456455
bitswapNetwork := bsnet.NewFromIpfsHost(n.PeerHost, n.Routing)
457-
n.Exchange = bitswap.New(ctx, n.Identity, bitswapNetwork, n.Blockstore, alwaysSendToPeer)
456+
n.Exchange = bitswap.New(ctx, bitswapNetwork, n.Blockstore)
458457

459458
size, err := n.getCacheSize()
460459
if err != nil {
@@ -919,7 +918,7 @@ func composeAddrsFactory(f, g p2pbhost.AddrsFactory) p2pbhost.AddrsFactory {
919918
}
920919

921920
// startListening on the network addresses
922-
func startListening(ctx context.Context, host p2phost.Host, cfg *config.Config) error {
921+
func startListening(host p2phost.Host, cfg *config.Config) error {
923922
listenAddrs, err := listenAddresses(cfg)
924923
if err != nil {
925924
return err

core/coreunix/add.go

-28
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ import (
99
gopath "path"
1010
"strconv"
1111

12-
bserv "github.com/ipfs/go-ipfs/blockservice"
1312
core "github.com/ipfs/go-ipfs/core"
14-
"github.com/ipfs/go-ipfs/exchange/offline"
1513
balanced "github.com/ipfs/go-ipfs/importer/balanced"
1614
ihelper "github.com/ipfs/go-ipfs/importer/helpers"
1715
trickle "github.com/ipfs/go-ipfs/importer/trickle"
@@ -20,8 +18,6 @@ import (
2018
"github.com/ipfs/go-ipfs/pin"
2119
unixfs "github.com/ipfs/go-ipfs/unixfs"
2220

23-
ds "gx/ipfs/QmPpegoMqhAEqjncrzArm7KVWAkCm78rqL2DPuNjhPrshg/go-datastore"
24-
syncds "gx/ipfs/QmPpegoMqhAEqjncrzArm7KVWAkCm78rqL2DPuNjhPrshg/go-datastore/sync"
2521
logging "gx/ipfs/QmRb5jh8z2E8hMGN2tkvs1yHynUanqnZ3UeKwgN1i9P1F8/go-log"
2622
bstore "gx/ipfs/QmTVDM4LCSUMFNQzbDLL9zQwp8usE6QHymFdh3h8vL9v6b/go-ipfs-blockstore"
2723
chunker "gx/ipfs/QmWo8jYc19ppG7YoTsrr2kEtLRbARTJho5oNXFTR6B7Peq/go-ipfs-chunker"
@@ -49,22 +45,6 @@ type Object struct {
4945
Size string
5046
}
5147

52-
type hiddenFileError struct {
53-
fileName string
54-
}
55-
56-
func (e *hiddenFileError) Error() string {
57-
return fmt.Sprintf("%s is a hidden file", e.fileName)
58-
}
59-
60-
type ignoreFileError struct {
61-
fileName string
62-
}
63-
64-
func (e *ignoreFileError) Error() string {
65-
return fmt.Sprintf("%s is an ignored file", e.fileName)
66-
}
67-
6848
type AddedObject struct {
6949
Name string
7050
Hash string `json:",omitempty"`
@@ -573,14 +553,6 @@ func outputDagnode(out chan interface{}, name string, dn ipld.Node) error {
573553
return nil
574554
}
575555

576-
// NewMemoryDagService builds and returns a new mem-datastore.
577-
func NewMemoryDagService() ipld.DAGService {
578-
// build mem-datastore for editor's intermediary nodes
579-
bs := bstore.NewBlockstore(syncds.MutexWrap(ds.NewMapDatastore()))
580-
bsrv := bserv.New(bs, offline.Exchange(bs))
581-
return dag.NewDAGService(bsrv)
582-
}
583-
584556
// from core/commands/object.go
585557
func getOutput(dagnode ipld.Node) (*Object, error) {
586558
c := dagnode.Cid()

exchange/bitswap/bitswap.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ var rebroadcastDelay = delay.Fixed(time.Minute)
6666
// BitSwapNetwork. This function registers the returned instance as the network
6767
// delegate.
6868
// Runs until context is cancelled.
69-
func New(parent context.Context, p peer.ID, network bsnet.BitSwapNetwork,
70-
bstore blockstore.Blockstore, nice bool) exchange.Interface {
69+
func New(parent context.Context, network bsnet.BitSwapNetwork,
70+
bstore blockstore.Blockstore) exchange.Interface {
7171

7272
// important to use provided parent context (since it may include important
7373
// loggable data). It's probably not a good idea to allow bitswap to be

exchange/bitswap/testutils.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,7 @@ func MkSession(ctx context.Context, net tn.Network, p testutil.Identity) Instanc
9999
panic(err.Error()) // FIXME perhaps change signature and return error.
100100
}
101101

102-
const alwaysSendToPeer = true
103-
104-
bs := New(ctx, p.ID(), adapter, bstore, alwaysSendToPeer).(*Bitswap)
102+
bs := New(ctx, adapter, bstore).(*Bitswap)
105103

106104
return Instance{
107105
Peer: p.ID(),

fuse/ipns/writerat.go

-29
This file was deleted.

importer/helpers/helpers.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import (
77

88
dag "github.com/ipfs/go-ipfs/merkledag"
99
ft "github.com/ipfs/go-ipfs/unixfs"
10-
pi "gx/ipfs/Qmb3jLEFAQrqdVgWUajqEyuuDoavkSq1XQXz6tWdFWF995/go-ipfs-posinfo"
1110

11+
pi "gx/ipfs/Qmb3jLEFAQrqdVgWUajqEyuuDoavkSq1XQXz6tWdFWF995/go-ipfs-posinfo"
1212
cid "gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid"
1313
ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
1414
)
@@ -32,7 +32,7 @@ var roughLinkSize = 34 + 8 + 5 // sha256 multihash + size + no name + protobuf
3232
// var DefaultLinksPerBlock = (roughLinkBlockSize / roughLinkSize)
3333
//
3434
// See calc_test.go
35-
var DefaultLinksPerBlock = (roughLinkBlockSize / roughLinkSize)
35+
var DefaultLinksPerBlock = roughLinkBlockSize / roughLinkSize
3636

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

0 commit comments

Comments
 (0)