Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

waitingForPeers waits forever #35

Open
haydenyoung opened this issue Sep 30, 2022 · 0 comments
Open

waitingForPeers waits forever #35

haydenyoung opened this issue Sep 30, 2022 · 0 comments

Comments

@haydenyoung
Copy link
Contributor

When direct connection is connecting, it calls waitForPeers to check that call peers listening for db updates are subscribed to the corresponding pubsub direct channel topic.

However, waitForPeers never returns. It gets stuck waiting for peers because of this line:

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

e should be the address of the peer as a hash, eg. 0x1234567890, but it appears in newer versions of libp2p, the peer is represented by an object called Ed25519PeerIdImpl and so the above checks fail because object comparison is not possible. Ed25519PeerIdImpl, does, however, expose the peer id as a string if Ed25519PeerIdImpl is explicitly cast to the String object.

The proposed fix is to map the peersToWait AND the peers arrays to string versions of each peer, resulting in an array of peer address strings, E.g.

const hasAllPeers = peersToWait.map(e => String(e)).map((e) => peers.map(e => String(e)).includes(e)).filter((e) => e === false).length === 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant