Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return new Promise((resolve, reject) => {
const handler = (err, peerInfo) => {
if (err) {
return reject(err);
}
this.peerBook.getAll().forEach((peer) => {
peer.multiaddrs.forEach((multiaddr) => {
peerInfo.multiaddrs.add(multiaddr);
resolve(peerInfo);
});
});
};
if (this.privateKey) {
PeerId.createFromPrivKey(this.privateKey, (err, id) => {
if (err) {
return reject(err);
}
PeerInfo.create(id, handler);
});
} else {
PeerInfo.create(handler);
}
});
}