Skip to content
This repository has been archived by the owner on Jul 7, 2024. It is now read-only.
/ Orion Public archive

Commit

Permalink
Merge pull request #109 from Siderus/feature/101-ipns-over-pub-sub
Browse files Browse the repository at this point in the history
Add IPNS over PubSub option
  • Loading branch information
kernelwhisperer authored May 16, 2018
2 parents 25a90f5 + 0a68901 commit d7cd8a8
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 4 deletions.
14 changes: 13 additions & 1 deletion app/daemon.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { fileSync as tmpFileSync } from 'tmp'
import request from 'request-promise-native'
import { app, dialog } from 'electron'
import pjson from '../package.json'
import Settings from 'electron-settings'

/**
* Execute an IPFS command asynchoniously,
Expand Down Expand Up @@ -113,7 +114,18 @@ export function getAPIVersion () {
*/
export function startIPFSDaemon () {
return new Promise((resolve, reject) => {
const ipfsProcess = spawnIPFSCommand('daemon', '--init', `--api=${global.IPFS_MULTIADDR_API}`)
const disablePubSubIPNS = Settings.getSync('disablePubSubIPNS')

const args = [
'--init',
`--api=${global.IPFS_MULTIADDR_API}`
]

if (!disablePubSubIPNS) {
args.push('--enable-namesys-pubsub')
}

const ipfsProcess = spawnIPFSCommand('daemon', ...args)

// Prepare temporary file for logging:
const tmpLog = tmpFileSync({ keep: true })
Expand Down
29 changes: 26 additions & 3 deletions app/windows/Settings/Components/ConnectivityPanel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ class ConnectivityPanel extends React.Component {
state = {
gateway: GatewayEnum.SIDERUS,
skipGatewayQuery: true,
runInBackground: true
runInBackground: true,
disablePubSubIPNS: false
}

componentWillMount () {
Expand All @@ -29,14 +30,16 @@ class ConnectivityPanel extends React.Component {
Promise.all([
Settings.get('gatewayURL'),
Settings.get('skipGatewayQuery'),
Settings.get('runInBackground')
Settings.get('runInBackground'),
Settings.get('disablePubSubIPNS')
])
// .then(console.log)
.then(values => this.setState({
gateway: values[0],
skipGatewayQuery: values[1] || false,
// the default (undefined) is considered true
runInBackground: typeof values[2] !== 'boolean' ? true : values[2]
runInBackground: typeof values[2] !== 'boolean' ? true : values[2],
disablePubSubIPNS: values[3] || false
}))
}

Expand Down Expand Up @@ -82,6 +85,20 @@ class ConnectivityPanel extends React.Component {
})
}

_handlePubSubIPNSChange = (event) => {
const nextValue = !this.state.disablePubSubIPNS
/**
* Save setting persistently
*/
Settings.setSync('disablePubSubIPNS', nextValue)
/**
* Update component's state
*/
this.setState({
disablePubSubIPNS: nextValue
})
}

render () {
if (this.props.navigationStore.selected !== 0) return null
if (!this.props.informationStore) return null
Expand Down Expand Up @@ -131,6 +148,12 @@ class ConnectivityPanel extends React.Component {
onChange={this._handleRunInBackgroundChange}
/>
}

<CheckBox
label="Disable IPNS over PubSub (experimental feature)"
checked={this.state.disablePubSubIPNS}
onChange={this._handlePubSubIPNSChange}
/>
</Pane>
)
}
Expand Down

0 comments on commit d7cd8a8

Please sign in to comment.