@libp2p/peer-store 11.2.2 → 11.2.3
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/index.d.ts +4 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +36 -68
- package/dist/src/index.js.map +1 -1
- package/dist/src/store.d.ts +18 -9
- package/dist/src/store.d.ts.map +1 -1
- package/dist/src/store.js +80 -27
- package/dist/src/store.js.map +1 -1
- package/dist/src/utils/bytes-to-peer.d.ts.map +1 -1
- package/dist/src/utils/bytes-to-peer.js +1 -4
- package/dist/src/utils/bytes-to-peer.js.map +1 -1
- package/dist/src/utils/dedupe-addresses.d.ts +2 -1
- package/dist/src/utils/dedupe-addresses.d.ts.map +1 -1
- package/dist/src/utils/dedupe-addresses.js +2 -2
- package/dist/src/utils/dedupe-addresses.js.map +1 -1
- package/dist/src/utils/to-peer-pb.d.ts +2 -1
- package/dist/src/utils/to-peer-pb.d.ts.map +1 -1
- package/dist/src/utils/to-peer-pb.js +7 -4
- package/dist/src/utils/to-peer-pb.js.map +1 -1
- package/package.json +12 -10
- package/src/index.ts +43 -70
- package/src/store.ts +100 -28
- package/src/utils/bytes-to-peer.ts +3 -5
- package/src/utils/dedupe-addresses.ts +3 -2
- package/src/utils/to-peer-pb.ts +12 -5
package/src/utils/to-peer-pb.ts
CHANGED
|
@@ -7,8 +7,9 @@ import type { AddressFilter } from '../index.js'
|
|
|
7
7
|
import type { Tag, Peer as PeerPB } from '../pb/peer.js'
|
|
8
8
|
import type { ExistingPeer } from '../store.js'
|
|
9
9
|
import type { PeerId, Address, PeerData, TagOptions } from '@libp2p/interface'
|
|
10
|
+
import type { AbortOptions } from '@multiformats/multiaddr'
|
|
10
11
|
|
|
11
|
-
export interface ToPBPeerOptions {
|
|
12
|
+
export interface ToPBPeerOptions extends AbortOptions {
|
|
12
13
|
addressFilter?: AddressFilter
|
|
13
14
|
existingPeer?: ExistingPeer
|
|
14
15
|
}
|
|
@@ -148,7 +149,8 @@ export async function toPeerPB (peerId: PeerId, data: Partial<PeerData>, strateg
|
|
|
148
149
|
peerId,
|
|
149
150
|
options.addressFilter ?? (async () => true),
|
|
150
151
|
addresses,
|
|
151
|
-
options.existingPeer?.peerPB.addresses
|
|
152
|
+
options.existingPeer?.peerPB.addresses,
|
|
153
|
+
options
|
|
152
154
|
),
|
|
153
155
|
protocols: [...protocols.values()].sort((a, b) => {
|
|
154
156
|
return a.localeCompare(b)
|
|
@@ -250,8 +252,13 @@ function mapTag (key: string, tag: any): Tag {
|
|
|
250
252
|
expiry = BigInt(Date.now() + Number(tag.ttl))
|
|
251
253
|
}
|
|
252
254
|
|
|
253
|
-
|
|
254
|
-
value: tag.value ?? 0
|
|
255
|
-
expiry
|
|
255
|
+
const output: Tag = {
|
|
256
|
+
value: tag.value ?? 0
|
|
256
257
|
}
|
|
258
|
+
|
|
259
|
+
if (expiry != null) {
|
|
260
|
+
output.expiry = expiry
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
return output
|
|
257
264
|
}
|