Skip to content

Instantly share code, notes, and snippets.

@daviddias
Created July 27, 2016 13:59
Show Gist options
  • Save daviddias/9aa8055c72dd654b5640517a81db8bed to your computer and use it in GitHub Desktop.
Save daviddias/9aa8055c72dd654b5640517a81db8bed to your computer and use it in GitHub Desktop.
const IPFS = require('ipfs')
const os = require('os')
const repoPath = os.tmpdir() + '/' + Math.random()
const node = new IPFS(repoPath)
node.init({}, (err) => {
if (err) { throw err }
node._repo.config.get((err, config) => {
if (err) { throw err }
config.Addresses = {
Swarm: [
'/ip4/127.0.0.1/tcp/10000',
'/ip4/127.0.0.1/tcp/20000/ws'
],
API: '',
Gateway: ''
}
node._repo.config.set(config, (err) => {
if (err) { throw err }
node.load((err) => {
if (err) { throw err }
node.goOnline((err) => {
if (err) { throw err }
console.log('Node is online')
})
})
})
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment