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

fix(connectivity): fixes to peer connectivity and friends #5004

Merged
merged 2 commits into from
Sep 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Commitment } from '@solana/web3.js'
import type { IridiumConfig } from '@satellite-im/iridium'

const nodes = process.env.NUXT_ENV_IRIDIUM_SYNC_NODES?.split(',') || [
'/ip4/localhost/tcp/443/wss/p2p/12D3KooWRgdhiJam4naWGYtgLXtc17ty89MMPvig41p9BhKG7FRW',
'/dns4/sync-ny.satellite.im/tcp/443/wss/p2p/12D3KooWRnsCHcpEWE6vPcrFc8sjGusu9xhy6s2PCevMMB24bsQm',
]
const gateways = process.env.NUXT_ENV_IRIDIUM_GATEWAYS?.split(',') || [
'https://satellite.infura-ipfs.io',
Expand Down
16 changes: 13 additions & 3 deletions libraries/Iridium/friends/FriendsManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,19 @@ export default class FriendsManager extends Emitter<IridiumFriendPubsub> {
await this.fetch()
logger.log(this.loggerTag, 'friends state loaded', this.state)

if (iridium.connector.p2p.hasNode) {
await this.startP2P()
}

iridium.connector.p2p.on('nodeReady', async () => {
await this.startP2P()
})

logger.info(this.loggerTag, 'initialized', this)
this.emit('ready', {})
}

async startP2P() {
// connect to all friends
await Promise.all(
[
Expand Down Expand Up @@ -126,9 +139,6 @@ export default class FriendsManager extends Emitter<IridiumFriendPubsub> {
},
].map((fn) => fn()),
)

logger.info(this.loggerTag, 'initialized', this)
this.emit('ready', {})
}

async stop() {
Expand Down