diff options
author | Anton Evangelatov <anton.evangelatov@gmail.com> | 2018-12-24 00:31:32 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-24 00:31:32 +0800 |
commit | 9e9fc87e70accf2b81be8772ab2ab0c914e95666 (patch) | |
tree | 410ccdefb083b08796a14ac03653a5319e9895d7 /swarm/api | |
parent | 335760bf0674ee553f3ca65afd6f29b6557d1b55 (diff) | |
download | go-tangerine-9e9fc87e70accf2b81be8772ab2ab0c914e95666.tar go-tangerine-9e9fc87e70accf2b81be8772ab2ab0c914e95666.tar.gz go-tangerine-9e9fc87e70accf2b81be8772ab2ab0c914e95666.tar.bz2 go-tangerine-9e9fc87e70accf2b81be8772ab2ab0c914e95666.tar.lz go-tangerine-9e9fc87e70accf2b81be8772ab2ab0c914e95666.tar.xz go-tangerine-9e9fc87e70accf2b81be8772ab2ab0c914e95666.tar.zst go-tangerine-9e9fc87e70accf2b81be8772ab2ab0c914e95666.zip |
swarm: remove unused/dead code (#18351)
Diffstat (limited to 'swarm/api')
-rw-r--r-- | swarm/api/api.go | 58 | ||||
-rw-r--r-- | swarm/api/client/client.go | 5 | ||||
-rw-r--r-- | swarm/api/storage.go | 20 | ||||
-rw-r--r-- | swarm/api/testapi.go | 12 | ||||
-rw-r--r-- | swarm/api/uri_test.go | 20 |
5 files changed, 9 insertions, 106 deletions
diff --git a/swarm/api/api.go b/swarm/api/api.go index 33a8e3539..c6ca1b577 100644 --- a/swarm/api/api.go +++ b/swarm/api/api.go @@ -51,10 +51,6 @@ import ( ) var ( - ErrNotFound = errors.New("not found") -) - -var ( apiResolveCount = metrics.NewRegisteredCounter("api.resolve.count", nil) apiResolveFail = metrics.NewRegisteredCounter("api.resolve.fail", nil) apiPutCount = metrics.NewRegisteredCounter("api.put.count", nil) @@ -136,13 +132,6 @@ func MultiResolverOptionWithResolver(r ResolveValidator, tld string) MultiResolv } } -// MultiResolverOptionWithNameHash is unused at the time of this writing -func MultiResolverOptionWithNameHash(nameHash func(string) common.Hash) MultiResolverOption { - return func(m *MultiResolver) { - m.nameHash = nameHash - } -} - // NewMultiResolver creates a new instance of MultiResolver. func NewMultiResolver(opts ...MultiResolverOption) (m *MultiResolver) { m = &MultiResolver{ @@ -173,40 +162,6 @@ func (m *MultiResolver) Resolve(addr string) (h common.Hash, err error) { return } -// ValidateOwner checks the ENS to validate that the owner of the given domain is the given eth address -func (m *MultiResolver) ValidateOwner(name string, address common.Address) (bool, error) { - rs, err := m.getResolveValidator(name) - if err != nil { - return false, err - } - var addr common.Address - for _, r := range rs { - addr, err = r.Owner(m.nameHash(name)) - // we hide the error if it is not for the last resolver we check - if err == nil { - return addr == address, nil - } - } - return false, err -} - -// HeaderByNumber uses the validator of the given domainname and retrieves the header for the given block number -func (m *MultiResolver) HeaderByNumber(ctx context.Context, name string, blockNr *big.Int) (*types.Header, error) { - rs, err := m.getResolveValidator(name) - if err != nil { - return nil, err - } - for _, r := range rs { - var header *types.Header - header, err = r.HeaderByNumber(ctx, blockNr) - // we hide the error if it is not for the last resolver we check - if err == nil { - return header, nil - } - } - return nil, err -} - // getResolveValidator uses the hostname to retrieve the resolver associated with the top level domain func (m *MultiResolver) getResolveValidator(name string) ([]ResolveValidator, error) { rs := m.resolvers[""] @@ -224,11 +179,6 @@ func (m *MultiResolver) getResolveValidator(name string) ([]ResolveValidator, er return rs, nil } -// SetNameHash sets the hasher function that hashes the domain into a name hash that ENS uses -func (m *MultiResolver) SetNameHash(nameHash func(string) common.Hash) { - m.nameHash = nameHash -} - /* API implements webserver/file system related content storage and retrieval on top of the FileStore @@ -265,9 +215,6 @@ func (a *API) Store(ctx context.Context, data io.Reader, size int64, toEncrypt b return a.fileStore.Store(ctx, data, size, toEncrypt) } -// ErrResolve is returned when an URI cannot be resolved from ENS. -type ErrResolve error - // Resolve a name into a content-addressed hash // where address could be an ENS name, or a content addressed hash 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 return a.feed.Update(ctx, request) } -// FeedsHashSize returned the size of the digest produced by Swarm feeds' hashing function -func (a *API) FeedsHashSize() int { - return a.feed.HashSize -} - // ErrCannotLoadFeedManifest is returned when looking up a feeds manifest fails var ErrCannotLoadFeedManifest = errors.New("Cannot load feed manifest") diff --git a/swarm/api/client/client.go b/swarm/api/client/client.go index f793ca8b8..5e293cca7 100644 --- a/swarm/api/client/client.go +++ b/swarm/api/client/client.go @@ -46,11 +46,6 @@ import ( ) var ( - DefaultGateway = "http://localhost:8500" - DefaultClient = NewClient(DefaultGateway) -) - -var ( ErrUnauthorized = errors.New("unauthorized") ) diff --git a/swarm/api/storage.go b/swarm/api/storage.go index 8a48fe5bc..254375b77 100644 --- a/swarm/api/storage.go +++ b/swarm/api/storage.go @@ -83,23 +83,3 @@ func (s *Storage) Get(ctx context.Context, bzzpath string) (*Response, error) { } return &Response{mimeType, status, expsize, string(body[:size])}, err } - -// Modify(rootHash, basePath, contentHash, contentType) takes th e manifest trie rooted in rootHash, -// and merge on to it. creating an entry w conentType (mime) -// -// DEPRECATED: Use the HTTP API instead -func (s *Storage) Modify(ctx context.Context, rootHash, path, contentHash, contentType string) (newRootHash string, err error) { - uri, err := Parse("bzz:/" + rootHash) - if err != nil { - return "", err - } - addr, err := s.api.Resolve(ctx, uri.Addr) - if err != nil { - return "", err - } - addr, err = s.api.Modify(ctx, addr, path, contentHash, contentType) - if err != nil { - return "", err - } - return addr.Hex(), nil -} diff --git a/swarm/api/testapi.go b/swarm/api/testapi.go index 4c7d0982b..6fec55f55 100644 --- a/swarm/api/testapi.go +++ b/swarm/api/testapi.go @@ -29,18 +29,6 @@ func NewControl(api *API, hive *network.Hive) *Control { return &Control{api, hive} } -//func (self *Control) BlockNetworkRead(on bool) { -// self.hive.BlockNetworkRead(on) -//} -// -//func (self *Control) SyncEnabled(on bool) { -// self.hive.SyncEnabled(on) -//} -// -//func (self *Control) SwapEnabled(on bool) { -// self.hive.SwapEnabled(on) -//} -// func (c *Control) Hive() string { return c.hive.String() } diff --git a/swarm/api/uri_test.go b/swarm/api/uri_test.go index ea649e273..a03874c43 100644 --- a/swarm/api/uri_test.go +++ b/swarm/api/uri_test.go @@ -26,17 +26,15 @@ import ( func TestParseURI(t *testing.T) { type test struct { - uri string - expectURI *URI - expectErr bool - expectRaw bool - expectImmutable bool - expectList bool - expectHash bool - expectDeprecatedRaw bool - expectDeprecatedImmutable bool - expectValidKey bool - expectAddr storage.Address + uri string + expectURI *URI + expectErr bool + expectRaw bool + expectImmutable bool + expectList bool + expectHash bool + expectValidKey bool + expectAddr storage.Address } tests := []test{ { |