1
0
mirror of https://github.com/oceanprotocol/commons.git synced 2023-03-15 18:03:00 +01:00

allow multiple nodes running at same time

This commit is contained in:
Matthias Kretschmann 2019-09-05 12:57:26 +02:00
parent 6db965b79a
commit 8127174fbd
Signed by: m
GPG Key ID: 606EEEF3C479A91F
2 changed files with 12 additions and 17 deletions

View File

@ -2,6 +2,8 @@
import Ipfs from 'ipfs'
import { useEffect, useState } from 'react'
import os from 'os'
import shortid from 'shortid'
let ipfs: any = null
let ipfsMessage = ''
@ -24,7 +26,16 @@ export default function useIpfs() {
const message = 'IPFS started'
console.time(message)
ipfs = await Ipfs.create()
ipfs = await Ipfs.create({
repo: `${os.homedir()}/.jsipfs-${shortid.generate()}`,
config: {
Addresses: {
// 0 for port so system just assigns a new free port
// to allow multiple nodes running at same time
Swarm: ['/ip4/0.0.0.0/tcp/0']
}
}
})
console.timeEnd(message)
ipfsMessage = message

View File

@ -5,22 +5,6 @@ import Files from '.'
const onChange = jest.fn()
// filter out IPFS node messages
const originalLog = console.log
beforeAll(() => {
console.log = (...args: any) => {
if (/Swarm listening/.test(args[0])) {
return
}
originalLog.call(console, ...args)
}
})
afterAll(() => {
console.log = originalLog
})
afterEach(() => {
mockAxios.reset()
})