mirror of https://codeberg.org/pzp/pzp-hub.git
no event.parsedAddress
This commit is contained in:
parent
96429e4af4
commit
a63a54987d
|
@ -1,4 +1,3 @@
|
||||||
const bs58 = require('bs58')
|
|
||||||
const cat = require('pull-cat')
|
const cat = require('pull-cat')
|
||||||
const Notify = require('pull-notify')
|
const Notify = require('pull-notify')
|
||||||
const pull = require('pull-stream')
|
const pull = require('pull-stream')
|
||||||
|
@ -19,13 +18,16 @@ function ErrorDuplex(message) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Array<[any, any]>} parsedAddress
|
* @param {string} addresses
|
||||||
* @returns {string | undefined}
|
* @returns {string | undefined}
|
||||||
*/
|
*/
|
||||||
function extractSHSEPubkey(parsedAddress) {
|
function extractSHSEPubkey(addresses) {
|
||||||
for (const [transport, transform] of parsedAddress) {
|
for (const address of addresses.split(';')) {
|
||||||
if (transform.name === 'shse') {
|
for (const [transport, transform] of address.split('~')) {
|
||||||
return bs58.encode(transform.pubkey)
|
const [name, pubkey, extra] = transform.split(':')
|
||||||
|
if (name === 'shse') {
|
||||||
|
return pubkey
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -82,7 +84,7 @@ module.exports = {
|
||||||
pull.filter(
|
pull.filter(
|
||||||
({ type }) => type === 'connecting-failed' || type === 'disconnected'
|
({ type }) => type === 'connecting-failed' || type === 'disconnected'
|
||||||
),
|
),
|
||||||
pull.map(({ parsedAddress }) => extractSHSEPubkey(parsedAddress)),
|
pull.map(({ address }) => extractSHSEPubkey(address)),
|
||||||
pull.filter((pubkey) => !!pubkey && attendants.has(pubkey)),
|
pull.filter((pubkey) => !!pubkey && attendants.has(pubkey)),
|
||||||
pull.drain((pubkey) => {
|
pull.drain((pubkey) => {
|
||||||
debug('farewell %s', pubkey)
|
debug('farewell %s', pubkey)
|
||||||
|
|
Loading…
Reference in New Issue