@libp2p/gossipsub 15.0.11 → 15.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +4 -4
- package/dist/src/utils/msgIdFn.d.ts +5 -0
- package/dist/src/utils/msgIdFn.d.ts.map +1 -1
- package/dist/src/utils/msgIdFn.js +13 -1
- package/dist/src/utils/msgIdFn.js.map +1 -1
- package/package.json +6 -6
- package/src/utils/msgIdFn.ts +17 -1
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import type { Message } from '../index.js';
|
|
2
|
+
import type { PublicKey } from '@libp2p/interface';
|
|
3
|
+
/**
|
|
4
|
+
* Generate a message id, based on the `key` and `seqno`
|
|
5
|
+
*/
|
|
6
|
+
export declare const msgId: (key: PublicKey, seqno: bigint) => Uint8Array;
|
|
2
7
|
/**
|
|
3
8
|
* Generate a message id, based on the `key` and `seqno`
|
|
4
9
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"msgIdFn.d.ts","sourceRoot":"","sources":["../../../src/utils/msgIdFn.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"msgIdFn.d.ts","sourceRoot":"","sources":["../../../src/utils/msgIdFn.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAElD;;GAEG;AACH,eAAO,MAAM,KAAK,GAAI,KAAK,SAAS,EAAE,OAAO,MAAM,KAAG,UASrD,CAAA;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAE,GAAG,EAAE,OAAO,GAAG,UAAU,CAS3D;AAED;;GAEG;AACH,wBAAsB,mBAAmB,CAAE,GAAG,EAAE,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,CAE5E"}
|
|
@@ -1,5 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { publicKeyToProtobuf } from '@libp2p/crypto/keys';
|
|
2
2
|
import { sha256 } from 'multiformats/hashes/sha2';
|
|
3
|
+
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string';
|
|
4
|
+
/**
|
|
5
|
+
* Generate a message id, based on the `key` and `seqno`
|
|
6
|
+
*/
|
|
7
|
+
export const msgId = (key, seqno) => {
|
|
8
|
+
const seqnoBytes = uint8ArrayFromString(seqno.toString(16).padStart(16, '0'), 'base16');
|
|
9
|
+
const keyBytes = publicKeyToProtobuf(key);
|
|
10
|
+
const msgId = new Uint8Array(keyBytes.byteLength + seqnoBytes.length);
|
|
11
|
+
msgId.set(keyBytes, 0);
|
|
12
|
+
msgId.set(seqnoBytes, keyBytes.byteLength);
|
|
13
|
+
return msgId;
|
|
14
|
+
};
|
|
3
15
|
/**
|
|
4
16
|
* Generate a message id, based on the `key` and `seqno`
|
|
5
17
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"msgIdFn.js","sourceRoot":"","sources":["../../../src/utils/msgIdFn.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"msgIdFn.js","sourceRoot":"","sources":["../../../src/utils/msgIdFn.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAA;AACjD,OAAO,EAAE,UAAU,IAAI,oBAAoB,EAAE,MAAM,yBAAyB,CAAA;AAI5E;;GAEG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,GAAc,EAAE,KAAa,EAAc,EAAE;IACjE,MAAM,UAAU,GAAG,oBAAoB,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,EAAE,EAAE,GAAG,CAAC,EAAE,QAAQ,CAAC,CAAA;IACvF,MAAM,QAAQ,GAAG,mBAAmB,CAAC,GAAG,CAAC,CAAA;IAEzC,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,QAAQ,CAAC,UAAU,GAAG,UAAU,CAAC,MAAM,CAAC,CAAA;IACrE,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAA;IACtB,KAAK,CAAC,GAAG,CAAC,UAAU,EAAE,QAAQ,CAAC,UAAU,CAAC,CAAA;IAE1C,OAAO,KAAK,CAAA;AACd,CAAC,CAAA;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAE,GAAY;IAC7C,IAAI,GAAG,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAA;IACjD,CAAC;IACD,sBAAsB;IACtB,IAAI,GAAG,CAAC,cAAc,IAAI,IAAI,EAAE,CAAC;QAAC,MAAM,KAAK,CAAC,qBAAqB,CAAC,CAAA;IAAC,CAAC;IAEtE,sCAAsC;IACtC,OAAO,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,IAAI,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,cAAc,CAAC,CAAA;AACjE,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAE,GAAY;IACrD,OAAO,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;AAChC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@libp2p/gossipsub",
|
|
3
|
-
"version": "15.0.
|
|
3
|
+
"version": "15.0.12",
|
|
4
4
|
"description": "A typescript implementation of gossipsub",
|
|
5
5
|
"files": [
|
|
6
6
|
"src",
|
|
@@ -43,6 +43,7 @@
|
|
|
43
43
|
},
|
|
44
44
|
"scripts": {
|
|
45
45
|
"lint": "aegir lint",
|
|
46
|
+
"dep-check": "aegir dep-check",
|
|
46
47
|
"release": "aegir release --no-types",
|
|
47
48
|
"build": "aegir build",
|
|
48
49
|
"generate": "protons ./src/message/rpc.proto",
|
|
@@ -73,9 +74,9 @@
|
|
|
73
74
|
"dependencies": {
|
|
74
75
|
"@libp2p/crypto": "^5.1.13",
|
|
75
76
|
"@libp2p/interface": "^3.1.0",
|
|
76
|
-
"@libp2p/interface-internal": "^3.0.
|
|
77
|
+
"@libp2p/interface-internal": "^3.0.10",
|
|
77
78
|
"@libp2p/peer-id": "^6.0.4",
|
|
78
|
-
"@libp2p/
|
|
79
|
+
"@libp2p/utils": "^7.0.10",
|
|
79
80
|
"@multiformats/multiaddr": "^13.0.1",
|
|
80
81
|
"denque": "^2.1.0",
|
|
81
82
|
"it-length-prefixed": "^10.0.1",
|
|
@@ -89,10 +90,9 @@
|
|
|
89
90
|
"devDependencies": {
|
|
90
91
|
"@chainsafe/as-sha256": "^1.2.0",
|
|
91
92
|
"@dapplion/benchmark": "^1.0.0",
|
|
92
|
-
"@libp2p/floodsub": "^11.0.
|
|
93
|
-
"@libp2p/interface-compliance-tests": "^7.0.10",
|
|
93
|
+
"@libp2p/floodsub": "^11.0.11",
|
|
94
94
|
"@libp2p/logger": "^6.2.2",
|
|
95
|
-
"@libp2p/peer-store": "^12.0.
|
|
95
|
+
"@libp2p/peer-store": "^12.0.10",
|
|
96
96
|
"@types/node": "^22.18.1",
|
|
97
97
|
"@types/sinon": "^20.0.0",
|
|
98
98
|
"abortable-iterator": "^5.1.0",
|
package/src/utils/msgIdFn.ts
CHANGED
|
@@ -1,6 +1,22 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { publicKeyToProtobuf } from '@libp2p/crypto/keys'
|
|
2
2
|
import { sha256 } from 'multiformats/hashes/sha2'
|
|
3
|
+
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
|
|
3
4
|
import type { Message } from '../index.js'
|
|
5
|
+
import type { PublicKey } from '@libp2p/interface'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Generate a message id, based on the `key` and `seqno`
|
|
9
|
+
*/
|
|
10
|
+
export const msgId = (key: PublicKey, seqno: bigint): Uint8Array => {
|
|
11
|
+
const seqnoBytes = uint8ArrayFromString(seqno.toString(16).padStart(16, '0'), 'base16')
|
|
12
|
+
const keyBytes = publicKeyToProtobuf(key)
|
|
13
|
+
|
|
14
|
+
const msgId = new Uint8Array(keyBytes.byteLength + seqnoBytes.length)
|
|
15
|
+
msgId.set(keyBytes, 0)
|
|
16
|
+
msgId.set(seqnoBytes, keyBytes.byteLength)
|
|
17
|
+
|
|
18
|
+
return msgId
|
|
19
|
+
}
|
|
4
20
|
|
|
5
21
|
/**
|
|
6
22
|
* Generate a message id, based on the `key` and `seqno`
|