Skip to content

Commit 9e9fc87

Browse files
authored
swarm: remove unused/dead code (#18351)
1 parent 335760b commit 9e9fc87

25 files changed

Lines changed: 19 additions & 400 deletions

‎cmd/swarm/flags.go‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,6 @@ var (
164164
Name: "topic",
165165
Usage: "User-defined topic this feed is tracking, hex encoded. Limited to 64 hexadecimal characters",
166166
}
167-
SwarmFeedDataOnCreateFlag = cli.StringFlag{
168-
Name: "data",
169-
Usage: "Initializes the feed with the given hex-encoded data. Data must be prefixed by 0x",
170-
}
171167
SwarmFeedManifestFlag = cli.StringFlag{
172168
Name: "manifest",
173169
Usage: "Refers to the feed through a manifest",

‎swarm/api/api.go‎

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,6 @@ import (
5050
opentracing "github.com/opentracing/opentracing-go"
5151
)
5252

53-
var (
54-
ErrNotFound = errors.New("not found")
55-
)
56-
5753
var (
5854
apiResolveCount = metrics.NewRegisteredCounter("api.resolve.count", nil)
5955
apiResolveFail = metrics.NewRegisteredCounter("api.resolve.fail", nil)
@@ -136,13 +132,6 @@ func MultiResolverOptionWithResolver(r ResolveValidator, tld string) MultiResolv
136132
}
137133
}
138134

139-
// MultiResolverOptionWithNameHash is unused at the time of this writing
140-
func MultiResolverOptionWithNameHash(nameHash func(string) common.Hash) MultiResolverOption {
141-
return func(m *MultiResolver) {
142-
m.nameHash = nameHash
143-
}
144-
}
145-
146135
// NewMultiResolver creates a new instance of MultiResolver.
147136
func NewMultiResolver(opts ...MultiResolverOption) (m *MultiResolver) {
148137
m = &MultiResolver{
@@ -173,40 +162,6 @@ func (m *MultiResolver) Resolve(addr string) (h common.Hash, err error) {
173162
return
174163
}
175164

176-
// ValidateOwner checks the ENS to validate that the owner of the given domain is the given eth address
177-
func (m *MultiResolver) ValidateOwner(name string, address common.Address) (bool, error) {
178-
rs, err := m.getResolveValidator(name)
179-
if err != nil {
180-
return false, err
181-
}
182-
var addr common.Address
183-
for _, r := range rs {
184-
addr, err = r.Owner(m.nameHash(name))
185-
// we hide the error if it is not for the last resolver we check
186-
if err == nil {
187-
return addr == address, nil
188-
}
189-
}
190-
return false, err
191-
}
192-
193-
// HeaderByNumber uses the validator of the given domainname and retrieves the header for the given block number
194-
func (m *MultiResolver) HeaderByNumber(ctx context.Context, name string, blockNr *big.Int) (*types.Header, error) {
195-
rs, err := m.getResolveValidator(name)
196-
if err != nil {
197-
return nil, err
198-
}
199-
for _, r := range rs {
200-
var header *types.Header
201-
header, err = r.HeaderByNumber(ctx, blockNr)
202-
// we hide the error if it is not for the last resolver we check
203-
if err == nil {
204-
return header, nil
205-
}
206-
}
207-
return nil, err
208-
}
209-
210165
// getResolveValidator uses the hostname to retrieve the resolver associated with the top level domain
211166
func (m *MultiResolver) getResolveValidator(name string) ([]ResolveValidator, error) {
212167
rs := m.resolvers[""]
@@ -224,11 +179,6 @@ func (m *MultiResolver) getResolveValidator(name string) ([]ResolveValidator, er
224179
return rs, nil
225180
}
226181

227-
// SetNameHash sets the hasher function that hashes the domain into a name hash that ENS uses
228-
func (m *MultiResolver) SetNameHash(nameHash func(string) common.Hash) {
229-
m.nameHash = nameHash
230-
}
231-
232182
/*
233183
API implements webserver/file system related content storage and retrieval
234184
on top of the FileStore
@@ -265,9 +215,6 @@ func (a *API) Store(ctx context.Context, data io.Reader, size int64, toEncrypt b
265215
return a.fileStore.Store(ctx, data, size, toEncrypt)
266216
}
267217

268-
// ErrResolve is returned when an URI cannot be resolved from ENS.
269-
type ErrResolve error
270-
271218
// Resolve a name into a content-addressed hash
272219
// where address could be an ENS name, or a content addressed hash
273220
func (a *API) Resolve(ctx context.Context, address string) (storage.Address, error) {
@@ -980,11 +927,6 @@ func (a *API) FeedsUpdate(ctx context.Context, request *feed.Request) (storage.A
980927
return a.feed.Update(ctx, request)
981928
}
982929

983-
// FeedsHashSize returned the size of the digest produced by Swarm feeds' hashing function
984-
func (a *API) FeedsHashSize() int {
985-
return a.feed.HashSize
986-
}
987-
988930
// ErrCannotLoadFeedManifest is returned when looking up a feeds manifest fails
989931
var ErrCannotLoadFeedManifest = errors.New("Cannot load feed manifest")
990932

‎swarm/api/client/client.go‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,6 @@ import (
4545
"github.com/pborman/uuid"
4646
)
4747

48-
var (
49-
DefaultGateway = "http://localhost:8500"
50-
DefaultClient = NewClient(DefaultGateway)
51-
)
52-
5348
var (
5449
ErrUnauthorized = errors.New("unauthorized")
5550
)

‎swarm/api/storage.go‎

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -83,23 +83,3 @@ func (s *Storage) Get(ctx context.Context, bzzpath string) (*Response, error) {
8383
}
8484
return &Response{mimeType, status, expsize, string(body[:size])}, err
8585
}
86-
87-
// Modify(rootHash, basePath, contentHash, contentType) takes th e manifest trie rooted in rootHash,
88-
// and merge on to it. creating an entry w conentType (mime)
89-
//
90-
// DEPRECATED: Use the HTTP API instead
91-
func (s *Storage) Modify(ctx context.Context, rootHash, path, contentHash, contentType string) (newRootHash string, err error) {
92-
uri, err := Parse("bzz:/" + rootHash)
93-
if err != nil {
94-
return "", err
95-
}
96-
addr, err := s.api.Resolve(ctx, uri.Addr)
97-
if err != nil {
98-
return "", err
99-
}
100-
addr, err = s.api.Modify(ctx, addr, path, contentHash, contentType)
101-
if err != nil {
102-
return "", err
103-
}
104-
return addr.Hex(), nil
105-
}

‎swarm/api/testapi.go‎

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,6 @@ func NewControl(api *API, hive *network.Hive) *Control {
2929
return &Control{api, hive}
3030
}
3131

32-
//func (self *Control) BlockNetworkRead(on bool) {
33-
// self.hive.BlockNetworkRead(on)
34-
//}
35-
//
36-
//func (self *Control) SyncEnabled(on bool) {
37-
// self.hive.SyncEnabled(on)
38-
//}
39-
//
40-
//func (self *Control) SwapEnabled(on bool) {
41-
// self.hive.SwapEnabled(on)
42-
//}
43-
//
4432
func (c *Control) Hive() string {
4533
return c.hive.String()
4634
}

‎swarm/api/uri_test.go‎

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,15 @@ import (
2626

2727
func TestParseURI(t *testing.T) {
2828
type test struct {
29-
uri string
30-
expectURI *URI
31-
expectErr bool
32-
expectRaw bool
33-
expectImmutable bool
34-
expectList bool
35-
expectHash bool
36-
expectDeprecatedRaw bool
37-
expectDeprecatedImmutable bool
38-
expectValidKey bool
39-
expectAddr storage.Address
29+
uri string
30+
expectURI *URI
31+
expectErr bool
32+
expectRaw bool
33+
expectImmutable bool
34+
expectList bool
35+
expectHash bool
36+
expectValidKey bool
37+
expectAddr storage.Address
4038
}
4139
tests := []test{
4240
{

‎swarm/network/bitvector/bitvector.go‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,3 @@ func (bv *BitVector) Set(i int, v bool) {
6060
func (bv *BitVector) Bytes() []byte {
6161
return bv.b
6262
}
63-
64-
func (bv *BitVector) Length() int {
65-
return bv.len
66-
}

‎swarm/network/protocol.go‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ import (
3535

3636
const (
3737
DefaultNetworkID = 3
38-
// ProtocolMaxMsgSize maximum allowed message size
39-
ProtocolMaxMsgSize = 10 * 1024 * 1024
4038
// timeout for waiting
4139
bzzHandshakeTimeout = 3000 * time.Millisecond
4240
)
@@ -250,11 +248,6 @@ func NewBzzPeer(p *protocols.Peer) *BzzPeer {
250248
return &BzzPeer{Peer: p, BzzAddr: NewAddr(p.Node())}
251249
}
252250

253-
// LastActive returns the time the peer was last active
254-
func (p *BzzPeer) LastActive() time.Time {
255-
return p.lastActive
256-
}
257-
258251
// ID returns the peer's underlay node identifier.
259252
func (p *BzzPeer) ID() enode.ID {
260253
// This is here to resolve a method tie: both protocols.Peer and BzzAddr are embedded

‎swarm/network/protocol_test.go‎

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import (
2020
"flag"
2121
"fmt"
2222
"os"
23-
"sync"
2423
"testing"
2524

2625
"github.com/ethereum/go-ethereum/log"
@@ -44,31 +43,7 @@ func init() {
4443
log.Root().SetHandler(log.LvlFilterHandler(log.Lvl(*loglevel), log.StreamHandler(os.Stderr, log.TerminalFormat(true))))
4544
}
4645

47-
type testStore struct {
48-
sync.Mutex
49-
50-
values map[string][]byte
51-
}
52-
53-
func (t *testStore) Load(key string) ([]byte, error) {
54-
t.Lock()
55-
defer t.Unlock()
56-
v, ok := t.values[key]
57-
if !ok {
58-
return nil, fmt.Errorf("key not found: %s", key)
59-
}
60-
return v, nil
61-
}
62-
63-
func (t *testStore) Save(key string, v []byte) error {
64-
t.Lock()
65-
defer t.Unlock()
66-
t.values[key] = v
67-
return nil
68-
}
69-
7046
func HandshakeMsgExchange(lhs, rhs *HandshakeMsg, id enode.ID) []p2ptest.Exchange {
71-
7247
return []p2ptest.Exchange{
7348
{
7449
Expects: []p2ptest.Expect{

‎swarm/network/stream/intervals/store_test.go‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,11 @@
1717
package intervals
1818

1919
import (
20-
"errors"
2120
"testing"
2221

2322
"github.com/ethereum/go-ethereum/swarm/state"
2423
)
2524

26-
var ErrNotFound = errors.New("not found")
27-
2825
// TestInmemoryStore tests basic functionality of InmemoryStore.
2926
func TestInmemoryStore(t *testing.T) {
3027
testStore(t, state.NewInmemoryStore())

0 commit comments

Comments
 (0)