提交 6e18a6b8 作者: Łukasz Magiera

coreapi: drop nameopt.Local in favour of api.Offline

License: MIT
Signed-off-by: 's avatarŁukasz Magiera <magik6k@gmail.com>
上级 50aea072
...@@ -20,7 +20,6 @@ type NamePublishSettings struct { ...@@ -20,7 +20,6 @@ type NamePublishSettings struct {
} }
type NameResolveSettings struct { type NameResolveSettings struct {
Local bool
Cache bool Cache bool
ResolveOpts []ropts.ResolveOpt ResolveOpts []ropts.ResolveOpt
...@@ -49,7 +48,6 @@ func NamePublishOptions(opts ...NamePublishOption) (*NamePublishSettings, error) ...@@ -49,7 +48,6 @@ func NamePublishOptions(opts ...NamePublishOption) (*NamePublishSettings, error)
func NameResolveOptions(opts ...NameResolveOption) (*NameResolveSettings, error) { func NameResolveOptions(opts ...NameResolveOption) (*NameResolveSettings, error) {
options := &NameResolveSettings{ options := &NameResolveSettings{
Local: false,
Cache: true, Cache: true,
} }
...@@ -106,15 +104,6 @@ func (nameOpts) TTL(ttl time.Duration) NamePublishOption { ...@@ -106,15 +104,6 @@ func (nameOpts) TTL(ttl time.Duration) NamePublishOption {
} }
} }
// Local is an option for Name.Resolve which specifies if the lookup should be
// offline. Default value is false
func (nameOpts) Local(local bool) NameResolveOption {
return func(settings *NameResolveSettings) error {
settings.Local = local
return nil
}
}
// Cache is an option for Name.Resolve which specifies if cache should be used. // Cache is an option for Name.Resolve which specifies if cache should be used.
// Default value is true // Default value is true
func (nameOpts) Cache(cache bool) NameResolveOption { func (nameOpts) Cache(cache bool) NameResolveOption {
......
...@@ -2,7 +2,6 @@ package coreapi ...@@ -2,7 +2,6 @@ package coreapi
import ( import (
"context" "context"
"errors"
"fmt" "fmt"
"strings" "strings"
"time" "time"
...@@ -16,7 +15,6 @@ import ( ...@@ -16,7 +15,6 @@ import (
ci "gx/ipfs/QmNiJiXwWE3kRhZrC5ej3kSjWHm337pYfhjLGSCDNKJP2s/go-libp2p-crypto" ci "gx/ipfs/QmNiJiXwWE3kRhZrC5ej3kSjWHm337pYfhjLGSCDNKJP2s/go-libp2p-crypto"
"gx/ipfs/QmY5Grm8pJdiSSVsYxx4uNRgweY72EmYwuSDbRnbFok3iY/go-libp2p-peer" "gx/ipfs/QmY5Grm8pJdiSSVsYxx4uNRgweY72EmYwuSDbRnbFok3iY/go-libp2p-peer"
ipath "gx/ipfs/QmZErC2Ay6WuGi96CPg316PwitdwgLo6RxZRqVjJjRj2MR/go-path" ipath "gx/ipfs/QmZErC2Ay6WuGi96CPg316PwitdwgLo6RxZRqVjJjRj2MR/go-path"
"gx/ipfs/QmdmWkx54g7VfVyxeG8ic84uf4G6Eq1GohuyKA3XDuJ8oC/go-ipfs-routing/offline"
) )
type NameAPI CoreAPI type NameAPI CoreAPI
...@@ -96,16 +94,6 @@ func (api *NameAPI) Search(ctx context.Context, name string, opts ...caopts.Name ...@@ -96,16 +94,6 @@ func (api *NameAPI) Search(ctx context.Context, name string, opts ...caopts.Name
var resolver namesys.Resolver = api.namesys var resolver namesys.Resolver = api.namesys
if options.Local && !options.Cache { //TODO: rm before offline/local global opt merge
return nil, errors.New("cannot specify both local and nocache")
}
//TODO: can replaced with api.WithOpt(opts.Api.Offline(true))
if options.Local {
offroute := offline.NewOfflineRouter(api.repo.Datastore(), api.recordValidator)
resolver = namesys.NewIpnsResolver(offroute)
}
if !options.Cache { if !options.Cache {
resolver = namesys.NewNameSystem(r, api.repo.Datastore(), 0) resolver = namesys.NewNameSystem(r, api.repo.Datastore(), 0)
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论