-
Notifications
You must be signed in to change notification settings - Fork 446
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
173367b
commit 8f40eb6
Showing
5 changed files
with
66 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
'use strict' | ||
|
||
const Envelope = require('./envelope') | ||
const PeerRecord = require('./peer-record') | ||
|
||
/** | ||
* Create (or update if existing) self peer record and store it in the AddressBook. | ||
* @param {libp2p} libp2p | ||
* @returns {Promise<void>} | ||
*/ | ||
async function updateSelfPeerRecord (libp2p) { | ||
const peerRecord = new PeerRecord({ | ||
peerId: libp2p.peerId, | ||
multiaddrs: libp2p.multiaddrs | ||
}) | ||
const envelope = await Envelope.seal(peerRecord, libp2p.peerId) | ||
libp2p.peerStore.addressBook.consumePeerRecord(envelope) | ||
} | ||
|
||
module.exports.updateSelfPeerRecord = updateSelfPeerRecord |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters