Skip to content

Commit f4532c4

Browse files
committed
fix(provider): add a varint 0 for http to match go-libipni
1 parent b02ad4a commit f4532c4

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

provider.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export class Provider {
4343
* @param {'bitswap' | 'http' | 'graphsync'} config.protocol - transfer protocol available
4444
* @param {GraphsyncMetadata} [config.metadata]
4545
*/
46-
constructor ({ peerId, addresses, protocol, metadata }) {
46+
constructor({ peerId, addresses, protocol, metadata }) {
4747
if (!protocol || !addresses || !peerId) {
4848
throw new Error('protocol, addresses, and peerId are required')
4949
}
@@ -63,8 +63,8 @@ export class Provider {
6363
* @param {'bitswap' | 'http' | 'graphsync'} protocol
6464
* @param {GraphsyncMetadata} [metadata] - required if protocol is `graphsync`
6565
*/
66-
encodeMetadata (protocol = this.protocol, metadata = this.metadata) {
67-
if (protocol === 'http') return HTTP_PREFIX
66+
encodeMetadata(protocol = this.protocol, metadata = this.metadata) {
67+
if (protocol === 'http') return concat([HTTP_PREFIX, new Uint8Array(varint.encode(0))])
6868
if (protocol === 'bitswap') return BITSWAP_PREFIX
6969
if (protocol === 'graphsync') {
7070
if (!metadata) throw new Error('metadata is required')
@@ -85,7 +85,7 @@ export class Provider {
8585
* spec: https://github.com/ipni/specs/blob/main/IPNI.md#extendedprovider
8686
* @param {import('./advertisement').Advertisement} ad
8787
**/
88-
signableBytes (ad) {
88+
signableBytes(ad) {
8989
const text = new TextEncoder()
9090
const providerOverride = ad.override ? 1 : 0
9191
return concat([

0 commit comments

Comments
 (0)