-
-
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
fix: ipfs dht put/get commands with peerIDs encoded as CIDs #7633
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,6 @@ import ( | |
path "github.com/ipfs/go-path" | ||
peer "github.com/libp2p/go-libp2p-core/peer" | ||
routing "github.com/libp2p/go-libp2p-core/routing" | ||
b58 "github.com/mr-tron/base58/base58" | ||
) | ||
|
||
var ErrNotDHT = errors.New("routing service is not a DHT") | ||
|
@@ -676,20 +675,15 @@ func printEvent(obj *routing.QueryEvent, out io.Writer, verbose bool, override p | |
|
||
func escapeDhtKey(s string) (string, error) { | ||
parts := path.SplitList(s) | ||
switch len(parts) { | ||
case 1: | ||
k, err := b58.Decode(s) | ||
if err != nil { | ||
return "", err | ||
} | ||
return string(k), nil | ||
case 3: | ||
k, err := b58.Decode(parts[2]) | ||
if err != nil { | ||
return "", err | ||
} | ||
return path.Join(append(parts[:2], string(k))), nil | ||
default: | ||
if len(parts) != 3 || | ||
parts[0] != "" || | ||
!(parts[1] == "ipns" || parts[1] == "pk") { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There doesn't seem like there's a reason to support anything other than these two namespaces. Should we even support querying for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wouldn't hard-code these. There's no reason not to just let the DHT handle it (in case we add a new validator). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think I'd rather this yell at us early. The problem is that we're using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Up to you. I just don't like having checks at multiple points. It's nice to be able to add a new record type without having to modify this check here. |
||
return "", errors.New("invalid key") | ||
} | ||
|
||
k, err := peer.Decode(parts[2]) | ||
if err != nil { | ||
return "", err | ||
} | ||
return path.Join(append(parts[:2], string(k))), nil | ||
} |
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.
What was this ever for?
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 for find-provider? But that's not an issue anymore.