ipfs-shipyard / ipfs-pubsub-1on1

1-to-1 communication channel over IPFS Pubsub between two peers
25 stars 11 forks source link

fix: Ensure peer addresses are being used when checking if all peers are connected. #36

Closed haydenyoung closed 1 year ago

haydenyoung commented 1 year ago

Checking for peers who are subscribed to direct connection messages is failing because peers cannot be filtered by object. Instead, convert the peer to its address and then check it against the subscription list.

haydenyoung commented 1 year ago

How about:

const stringPeers = peers.map(e => String(e));
const hasAllPeers = peersToWait.map(e => String(e)).map((e) => stringPeers.includes(e)).filter((e) => e === false).length === 0

Thanks @julienmalard. I used idPeers and idPeersToWait as I felt id better reflected the info in those arrays. Happy to change, though, if you feel "string" is more acceptable.

haydenyoung commented 1 year ago

This PR now addresses the db sync on peer connect issue as well.

julienmalard commented 1 year ago

I like your variable names better too @haydenyoung ! Anyways we'll see what the maintainers think.

aphelionz commented 1 year ago

hi @alanshaw how are you? :) Might you be able to merge this or point us in the direction of somebody who could?

julienmalard commented 1 year ago

@haadcode @alanshaw Would it be possible to publish a release on NPM so that this could be update as an orbit-db dependency as well?