From fdc975aff99f1b7210c2af563f4aab0d230c7c1e Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Tue, 20 Mar 2018 18:13:13 +0000 Subject: [PATCH 1/2] feat: default profile as dhtclient --- src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index f239a5ef5..389d5b2de 100644 --- a/src/index.js +++ b/src/index.js @@ -72,7 +72,7 @@ function onStartDaemon (node) { } } - node.start((err, api) => { + node.start(['--routing=dhtclient'], (err, api) => { if (err) { handleKnownErrors(err) return From 3ffb2d80ccb9e86a4490e1b5e49cbec9bc609886 Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Tue, 20 Mar 2018 18:27:24 +0000 Subject: [PATCH 2/2] add setting to pane --- src/config.js | 4 +++- src/index.js | 7 ++++++- src/panes/Settings.js | 10 ++++++++++ src/utils/key-value-store.js | 4 ++-- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/config.js b/src/config.js index c4b4629d2..ac33534cb 100644 --- a/src/config.js +++ b/src/config.js @@ -30,7 +30,9 @@ function ensurePath (path) { const ipfsAppData = ensurePath(path.join(app.getPath('appData'), 'ipfs-desktop')) const logsPath = ensurePath(path.join(ipfsAppData, 'logs')) -const settingsStore = new KeyValueStore(path.join(ipfsAppData, 'config.json')) +const settingsStore = new KeyValueStore(path.join(ipfsAppData, 'config.json'), { + dhtClient: true +}) if (!settingsStore.get('ipfsPath')) { const p = path.join(process.env.IPFS_PATH || (process.env.HOME || process.env.USERPROFILE), '.ipfs') diff --git a/src/index.js b/src/index.js index 389d5b2de..7831161ae 100644 --- a/src/index.js +++ b/src/index.js @@ -72,7 +72,12 @@ function onStartDaemon (node) { } } - node.start(['--routing=dhtclient'], (err, api) => { + const flags = [] + if (config.settingsStore.get('dhtClient')) { + flags.push('--routing=dhtclient') + } + + node.start(flags, (err, api) => { if (err) { handleKnownErrors(err) return diff --git a/src/panes/Settings.js b/src/panes/Settings.js index 86cf21bfd..7e60a3ec7 100644 --- a/src/panes/Settings.js +++ b/src/panes/Settings.js @@ -41,6 +41,16 @@ const options = [ ) }, + { + title: 'DHT client profile', + setting: 'dhtClient', + description: ( + + Make your IPFS node act as a DHT client and not a DHT server, consuming less network and battery. + Restarting your node is required. + + ) + }, { title: 'Light theme', setting: 'lightTheme' diff --git a/src/utils/key-value-store.js b/src/utils/key-value-store.js index b3603de7e..a81e374fe 100644 --- a/src/utils/key-value-store.js +++ b/src/utils/key-value-store.js @@ -5,8 +5,8 @@ import FileStore from './file-store' * @extends FileStore */ export default class KeyValueStore extends FileStore { - constructor (location) { - super(location, {}) + constructor (location, d = {}) { + super(location, d) } /**