no event.parsedAddress

This commit is contained in:
Andre Staltz 2024-01-12 17:11:39 +02:00
parent 96429e4af4
commit a63a54987d
No known key found for this signature in database
GPG Key ID: 9EDE23EA7E8A4890
1 changed files with 9 additions and 7 deletions

View File

@ -1,4 +1,3 @@
const bs58 = require('bs58')
const cat = require('pull-cat')
const Notify = require('pull-notify')
const pull = require('pull-stream')
@ -19,13 +18,16 @@ function ErrorDuplex(message) {
}
/**
* @param {Array<[any, any]>} parsedAddress
* @param {string} addresses
* @returns {string | undefined}
*/
function extractSHSEPubkey(parsedAddress) {
for (const [transport, transform] of parsedAddress) {
if (transform.name === 'shse') {
return bs58.encode(transform.pubkey)
function extractSHSEPubkey(addresses) {
for (const address of addresses.split(';')) {
for (const [transport, transform] of address.split('~')) {
const [name, pubkey, extra] = transform.split(':')
if (name === 'shse') {
return pubkey
}
}
}
}
@ -82,7 +84,7 @@ module.exports = {
pull.filter(
({ type }) => type === 'connecting-failed' || type === 'disconnected'
),
pull.map(({ parsedAddress }) => extractSHSEPubkey(parsedAddress)),
pull.map(({ address }) => extractSHSEPubkey(address)),
pull.filter((pubkey) => !!pubkey && attendants.has(pubkey)),
pull.drain((pubkey) => {
debug('farewell %s', pubkey)