Skip to content

Commit

Permalink
feat(devtools): added 'IPFS Bootstrap' toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
aeddi committed Nov 9, 2018
1 parent 4a1d0de commit 64c0339
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
Expand Up @@ -25,6 +25,7 @@ export default class Network extends PureComponent {
default_trans: false,
bluetooth_trans: false,
default_bootstrap: false,
ipfs_bootstrap: false,
custom_bootstrap: [],
mdns: false,
relay: false,
Expand All @@ -38,6 +39,7 @@ export default class Network extends PureComponent {
(this.state.default_trans !== this.currentConfig.DefaultTransport ||
this.state.bluetooth_trans !== this.currentConfig.BluetoothTransport ||
this.state.default_bootstrap !== this.currentConfig.DefaultBootstrap ||
this.state.ipfs_bootstrap !== this.currentConfig.IPFSBootstrap ||
this.state.custom_bootstrap !== this.currentConfig.CustomBootstrap ||
this.state.mdns !== this.currentConfig.MDNS ||
this.state.relay !== this.currentConfig.Relay)
Expand All @@ -58,6 +60,7 @@ export default class Network extends PureComponent {
DefaultTransport: this.state.default_trans,
BluetoothTransport: this.state.bluetooth_trans,
DefaultBootstrap: this.state.default_bootstrap,
IPFSBootstrap: this.state.ipfs_bootstrap,
CustomBootstrap: this.state.custom_bootstrap,
MDNS: this.state.mdns,
Relay: this.state.relay,
Expand All @@ -84,6 +87,7 @@ export default class Network extends PureComponent {
default_trans: this.currentConfig.DefaultTransport,
bluetooth_trans: this.currentConfig.BluetoothTransport,
default_bootstrap: this.currentConfig.DefaultBootstrap,
ipfs_bootstrap: this.currentConfig.IPFSBootstrap,
custom_bootstrap: this.currentConfig.CustomBootstrap,
mdns: this.currentConfig.MDNS,
relay: this.currentConfig.Relay,
Expand Down Expand Up @@ -145,6 +149,21 @@ export default class Network extends PureComponent {
/>
}
/>
<Menu.Item
title='IPFS bootstrap'
customRight={
<Switch
justify='end'
disabled={!this.state.loaded}
value={this.state.ipfs_bootstrap}
onValueChange={value => {
this.setState({ ipfs_bootstrap: value }, () => {
this.hasConfigChanged()
})
}}
/>
}
/>
<Menu.Item
title='Custom bootstrap (not implem. yet)'
onPress={() => this.hasConfigChanged()}
Expand Down
7 changes: 5 additions & 2 deletions client/react-native/gomobile/core/network.go
Expand Up @@ -12,6 +12,7 @@ type networkConfig struct {
DefaultTransport bool
BluetoothTransport bool
DefaultBootstrap bool
IPFSBootstrap bool
CustomBootstrap []string
MDNS bool
Relay bool
Expand All @@ -37,10 +38,12 @@ func createNetworkConfig() (*account.P2PNetworkOptions, error) {
transport = append(transport, "ble")
bind = append(bind, defaultBLEBind)
}

if netConf.DefaultBootstrap {
bootstrap = append(bootstrap, p2p.DefaultBootstrap...)
}
if netConf.IPFSBootstrap {
bootstrap = append(bootstrap, p2p.BootstrapIpfs...)
}
bootstrap = append(bootstrap, netConf.CustomBootstrap...)

return &account.P2PNetworkOptions{
Expand All @@ -59,7 +62,7 @@ func GetNetworkConfig() string {
}

func UpdateNetworkConfig(jsonConf string) error {
waitDaemon()
waitDaemon(accountName)
currentAccount, _ := account.Get(accountName)

var newNetworkConfig networkConfig
Expand Down

0 comments on commit 64c0339

Please sign in to comment.