-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
namesys: add entry to DHT cache after publish #3501
Conversation
License: MIT Signed-off-by: Jakub Sztandera <[email protected]>
0b9a8b5
to
9fe9d9e
Compare
@whyrusleeping it isn't supper nice solution but without some refactor there isn't anything much better might be done. |
path "github.com/ipfs/go-ipfs/path" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why cant this be done at a slightly lower layer? Is it because the dht publisher and the dht resolver are different bits of code?
if err != nil { | ||
return err | ||
} | ||
ns.addToDHTCache(name, value, time.Now().Add(time.Hour*24)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets pull this magic number out and justify it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is the same as in publisher.go, should I add comment for it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or extract it from publisher?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd extract it from both, and give it a small comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets just call it DefaultRecordTTL
(i had to go look at it again to remember what exactly this was)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hah, gave it the same name without reading this. <3
var err error | ||
value, err = path.ParsePath(value.String()) | ||
if err != nil { | ||
log.Error("could not parse path") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe add the actual error to this? might aid in debugging random error messages
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is only cache, I didn't want it to fail the publish (as it was already published and we can't revert it).
return ns.publishers["/ipns/"].PublishWithEOL(ctx, name, val, eol) | ||
func (ns *mpns) addToDHTCache(key ci.PrivKey, value path.Path, eol time.Time) { | ||
var err error | ||
value, err = path.ParsePath(value.String()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wait, why are we converting the thing to a string, then back to a path?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes as the publisher can publish hash only but resolver will sanitize this value to be /ipfs/CID
which is what ParsePath does.
License: MIT Signed-off-by: Jakub Sztandera <[email protected]>
Yes, they are separate modules that don't know about each others existence. |
Is this problem IPNS specific? I love how this PR solves the problem in hand without changing much code, but I see it as a temporary fix that will need to be removed after the real issue has been addressed. The caching could be moved into the DHT-based IPRS implementation, so the /pk/ namespace could benefit from it as well. Namesys uses both. I am not aware of other IPRS namespaces, but probably it would apply to any record types. |
IPRS doesn't exist yet, I like to call IPNS a huge PoC that mutable data is possible even though the content is immutable. Yes, after IPRS is designed, speced out, and implemented it can be moved into one place with infrastructure that will include caching of self published record in its design. When code of namesys was written it wasn't a feature that was taken into account. |
License: MIT Signed-off-by: Jakub Sztandera <[email protected]>
if err != nil { | ||
return err | ||
} | ||
ns.addToDHTCache(name, value, time.Now().Add(DefaultRecortTTL)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: DefaultRecordTTL
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Me and my typos. Sorry.
License: MIT Signed-off-by: Jakub Sztandera <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks @Kubuxu
I am still experiencing slow ipns resolving. For a minute after I publish it will be fast, but then it takes a very long time. |
Resolves #2078
License: MIT
Signed-off-by: Jakub Sztandera [email protected]