Skip to content

Commit

Permalink
namesys: fix case where there is no cache
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
  • Loading branch information
Kubuxu committed Dec 15, 2016
1 parent 9e8d108 commit 0864c8e
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions namesys/namesys.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,16 @@ func (ns *mpns) PublishWithEOL(ctx context.Context, name ci.PrivKey, value path.
}

func (ns *mpns) addToDHTCache(key ci.PrivKey, value path.Path, eol time.Time) {
rr, ok := ns.resolvers["dht"].(*routingResolver)
if !ok {
// should never happen, purely for sanity
log.Panicf("unexpected type %T as DHT resolver.", ns.resolvers["dht"])
}
if rr.cache == nil {
// resolver has no caching
return
}

var err error
value, err = path.ParsePath(value.String())
if err != nil {
Expand All @@ -120,11 +130,6 @@ func (ns *mpns) addToDHTCache(key ci.PrivKey, value path.Path, eol time.Time) {
return
}

rr, ok := ns.resolvers["dht"].(*routingResolver)
if !ok {
// should never happen, purely for sanity
log.Panicf("unexpected type %T as DHT resolver.", ns.resolvers["dht"])
}
if time.Now().Add(DefaultResolverCacheTTL).Before(eol) {
eol = time.Now().Add(DefaultResolverCacheTTL)
}
Expand Down

0 comments on commit 0864c8e

Please sign in to comment.