Merge pull request #87 from Permissionless-Software-Foundation/ct-unstable

Subscribing to chat channel at startup
This commit is contained in:
Chris Troutner
2022-05-26 09:14:50 -07:00
committed by GitHub
5 changed files with 29 additions and 1 deletions
+6
View File
@@ -98,6 +98,12 @@ class Server {
await controllers.attachControllers(app)
}
// Display configuration settings
console.log('\nConfiguration:')
console.log(`Circuit Relay: ${config.isCircuitRelay}`)
console.log(`IPFS TCP port: ${config.ipfsTcpPort}`)
console.log(`IPFS WS port: ${config.ipfsWsPort}\n`)
return app
} catch (err) {
console.error('Could not start server. Error: ', err)
+3 -1
View File
@@ -85,5 +85,7 @@ module.exports = {
ipfsHost: process.env.IPFS_HOST ? process.env.IPFS_HOST : 'localhost',
ipfsApiPort: process.env.IPFS_API_PORT
? parseInt(process.env.IPFS_API_PORT)
: 5001
: 5001,
chatPubSubChan: 'psf-ipfs-chat-001'
}
+4
View File
@@ -2,6 +2,7 @@
top-level IPFS library that combines the individual IPFS-based libraries.
*/
// Local libraries
const IpfsAdapter = require('./ipfs')
const IpfsCoordAdapter = require('./ipfs-coord')
@@ -36,6 +37,9 @@ class IPFS {
await this.ipfsCoordAdapter.start()
console.log('ipfs-coord is ready.')
// Subscribe to the chat pubsub channel
await this.ipfsCoordAdapter.subscribeToChat()
return true
} catch (err) {
console.error('Error in adapters/ipfs/index.js/start()')
+14
View File
@@ -97,6 +97,20 @@ class IpfsCoordAdapter {
throw err
}
}
// Subscribe to the chat pubsub channel
async subscribeToChat () {
try {
await this.ipfsCoord.adapters.pubsub.subscribeToPubsubChannel(
this.config.chatPubSubChan,
console.log,
this.ipfsCoord.thisNode
)
} catch (err) {
console.error('Error in subscribeToChat')
throw err
}
}
}
module.exports = IpfsCoordAdapter
+2
View File
@@ -8,6 +8,8 @@ class IPFSCoord {
}
async start () {}
async subscribeToChat() {}
}
module.exports = IPFSCoord