From 80222b8474396aaa070fb44d859965ab14080f48 Mon Sep 17 00:00:00 2001 From: Alex Potsides Date: Wed, 10 May 2023 06:43:31 +0100 Subject: [PATCH] fix: expose peerstore consume peer record method (#398) This method lets gossipsub consume a peer record. --- packages/interface-peer-store/src/index.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/packages/interface-peer-store/src/index.ts b/packages/interface-peer-store/src/index.ts index 470cd9d58..71aa2581f 100644 --- a/packages/interface-peer-store/src/index.ts +++ b/packages/interface-peer-store/src/index.ts @@ -234,4 +234,19 @@ export interface PeerStore { * ``` */ merge: (id: PeerId, data: PeerData) => Promise + + /** + * Unmarshal and verify a signed peer record, extract the multiaddrs and + * overwrite the stored addresses for the peer. + * + * Optionally pass an expected PeerId to verify that the peer record was + * signed by that peer. + * + * @example + * + * ```js + * await peerStore.consumePeerRecord(buf, expectedPeer) + * ``` + */ + consumePeerRecord: (buf: Uint8Array, expectedPeer?: PeerId) => Promise }