mirror of
https://github.com/Permissionless-Software-Foundation/ipfs-bch-wallet-service.git
synced 2026-09-21 16:52:03 -07:00
feat(JSON RPC): Added initial router for JSON RPC
This commit is contained in:
+5
-1
@@ -15,6 +15,8 @@ const config = require('../config') // this first.
|
||||
const IPFSLib = require('../src/lib/ipfs')
|
||||
const AdminLib = require('../src/lib/admin')
|
||||
const adminLib = new AdminLib()
|
||||
const JSONRPC = require('../src/rpc')
|
||||
const rpc = new JSONRPC()
|
||||
|
||||
const errorMiddleware = require('../src/middleware')
|
||||
const wlogger = require('../src/lib/wlogger')
|
||||
@@ -71,7 +73,9 @@ async function startServer () {
|
||||
if (success) console.log('System admin user created.')
|
||||
|
||||
// Start the IPFS node.
|
||||
const ipfsLib = new IPFSLib()
|
||||
const ipfsLib = new IPFSLib({
|
||||
rpc
|
||||
})
|
||||
await ipfsLib.start()
|
||||
|
||||
return app
|
||||
|
||||
+7
-1
@@ -14,6 +14,11 @@ class IPFSLib {
|
||||
this.IPFS = IPFS
|
||||
this.IpfsCoord = IpfsCoord
|
||||
this.bchjs = new BCHJS()
|
||||
|
||||
this.rpc = {}
|
||||
if (localConfig.rpc) {
|
||||
this.rpc = localConfig.rpc
|
||||
}
|
||||
}
|
||||
|
||||
// This is a 'macro' start method. It kicks off several smaller methods that
|
||||
@@ -57,7 +62,8 @@ class IPFSLib {
|
||||
this.ipfsCoord = new this.IpfsCoord({
|
||||
ipfs: this.ipfs,
|
||||
type: 'node.js',
|
||||
bchjs: this.bchjs
|
||||
bchjs: this.bchjs,
|
||||
privateLog: this.rpc.router
|
||||
})
|
||||
|
||||
await this.ipfsCoord.isReady()
|
||||
|
||||
@@ -6,6 +6,17 @@ class JSONRPC {
|
||||
constructor (localConfig) {
|
||||
console.log('instantiating JSONRPC')
|
||||
}
|
||||
|
||||
// This method takes a raw string of data from IPFS, parses it, and determins
|
||||
// which controller to route the instruction to.
|
||||
router (str) {
|
||||
try {
|
||||
console.log('router str: ', str)
|
||||
} catch (err) {
|
||||
console.error('Error in rpc router()')
|
||||
throw err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = JSONRPC
|
||||
|
||||
Reference in New Issue
Block a user