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

Add IPNS over PubSub option #109

Merged
merged 1 commit into from
May 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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