@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.
@@ -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
- return {
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
  }