coreapi: drop nameopt.Local in favour of api.Offline
License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
Łukasz Magiera committed
Dec 10, 2018 at 14:31 UTC
6e18a6b85757cceae2b30688f7245f8b5f4e54db
2 files changed
-23
core/coreapi/interface/options/name.go
-11
@@ -20,7 +20,6 @@ type NamePublishSettings struct {
20
}
21
22
type NameResolveSettings struct {
23
- Local bool
23
Cache bool
24
25
ResolveOpts []ropts.ResolveOpt
@@ -49,7 +48,6 @@ func NamePublishOptions(opts ...NamePublishOption) (*NamePublishSettings, error)
48
49
func NameResolveOptions(opts ...NameResolveOption) (*NameResolveSettings, error) {
50
options := &NameResolveSettings{
52
- Local: false,
51
Cache: true,
52
}
53
@@ -106,15 +104,6 @@ func (nameOpts) TTL(ttl time.Duration) NamePublishOption {
104
}
105
}
106
109
-// Local is an option for Name.Resolve which specifies if the lookup should be
110
-// offline. Default value is false
111
-func (nameOpts) Local(local bool) NameResolveOption {
112
- return func(settings *NameResolveSettings) error {
113
- settings.Local = local
114
- return nil
115
- }
116
-}
117
-
107
// Cache is an option for Name.Resolve which specifies if cache should be used.
108
// Default value is true
109
func (nameOpts) Cache(cache bool) NameResolveOption {
core/coreapi/name.go
-12
@@ -2,7 +2,6 @@ package coreapi
2
3
import (
4
"context"
5
- "errors"
5
"fmt"
6
"strings"
7
"time"
@@ -16,7 +15,6 @@ import (
15
ci "gx/ipfs/QmNiJiXwWE3kRhZrC5ej3kSjWHm337pYfhjLGSCDNKJP2s/go-libp2p-crypto"
16
"gx/ipfs/QmY5Grm8pJdiSSVsYxx4uNRgweY72EmYwuSDbRnbFok3iY/go-libp2p-peer"
17
ipath "gx/ipfs/QmZErC2Ay6WuGi96CPg316PwitdwgLo6RxZRqVjJjRj2MR/go-path"
19
- "gx/ipfs/QmdmWkx54g7VfVyxeG8ic84uf4G6Eq1GohuyKA3XDuJ8oC/go-ipfs-routing/offline"
18
)
19
20
type NameAPI CoreAPI
@@ -96,16 +94,6 @@ func (api *NameAPI) Search(ctx context.Context, name string, opts ...caopts.Name
94
95
var resolver namesys.Resolver = api.namesys
96
99
- if options.Local && !options.Cache { //TODO: rm before offline/local global opt merge
100
- return nil, errors.New("cannot specify both local and nocache")
101
- }
102
-
103
- //TODO: can replaced with api.WithOpt(opts.Api.Offline(true))
104
- if options.Local {
105
- offroute := offline.NewOfflineRouter(api.repo.Datastore(), api.recordValidator)
106
- resolver = namesys.NewIpnsResolver(offroute)
107
- }
108
-
97
if !options.Cache {
98
resolver = namesys.NewNameSystem(r, api.repo.Datastore(), 0)
99
}