-
Notifications
You must be signed in to change notification settings - Fork 452
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix!: accept Uint8Arrays as keys (#2909)
To allow use cases like fetching IPNS records in a way compatible with go-libp2p we need to send binary as fetch identifiers. JavaScript strings are UTF-16 so we can't round-trip binary reliably since some byte sequences are interpreted as multi-byte or otherwise non-printable characters. Instead we need to accept Uint8Arrays and send them over the wire as-is. This is a backwards compatible change as far as interop goes since protobuf `bytes` and `string` types are identical on the wire, but it's breaking for API consumers in that the lookup function now needs to accept a `Uint8Array` identifier instead of a `string`. Refs: libp2p/specs#656 BREAKING CHANGE: registered lookup functions now receive a Uint8Array identifier instead of a string
- Loading branch information
1 parent
60ccf1a
commit b56d918
Showing
7 changed files
with
91 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,16 @@ | ||
syntax = "proto3"; | ||
|
||
message FetchRequest { | ||
string identifier = 1; | ||
bytes identifier = 1; | ||
} | ||
|
||
message FetchResponse { | ||
StatusCode status = 1; | ||
enum StatusCode { | ||
OK = 0; | ||
NOT_FOUND = 1; | ||
ERROR = 2; | ||
} | ||
bytes data = 2; | ||
enum StatusCode { | ||
OK = 0; | ||
NOT_FOUND = 1; | ||
ERROR = 2; | ||
} | ||
|
||
StatusCode status = 1; | ||
bytes data = 2; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters