make Waku the default protocol

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2020-08-19 14:06:41 +02:00 committed by Jakub
parent 6fb5cd2154
commit ea47f07b96
2 changed files with 22 additions and 8 deletions

View File

@ -52,15 +52,15 @@ In order to adjust logging settings you'd need:
``` ```
Valid `LogLevel` settings are: `ERROR`, `WARN`, `INFO`, `DEBUG`, `TRACE` Valid `LogLevel` settings are: `ERROR`, `WARN`, `INFO`, `DEBUG`, `TRACE`
## `WhisperConfig` ## `WakuConfig`
If you want your node to relay Whisper(SHH) protocol messages you'll want to include this: If you want your node to relay Waku(modified Whisper) protocol messages you'll want to include this:
```json ```json
{ {
"WhisperConfig": { "WakuConfig": {
"Enabled": true, "Enabled": true,
"EnableMailServer": true, "EnableMailServer": true,
"LightClient": false, "DataDir": "/tmp/status-go-data/waku",
"MailServerPassword": "status-offline-inbox" "MailServerPassword": "status-offline-inbox"
} }
} }

View File

@ -20,6 +20,7 @@ import (
"github.com/status-im/status-go/eth-node/crypto" "github.com/status-im/status-go/eth-node/crypto"
"github.com/status-im/status-go/eth-node/types" "github.com/status-im/status-go/eth-node/types"
"github.com/status-im/status-go/static" "github.com/status-im/status-go/static"
wakucommon "github.com/status-im/status-go/waku/common"
"github.com/status-im/status-go/whisper/v6" "github.com/status-im/status-go/whisper/v6"
) )
@ -584,7 +585,7 @@ func NewNodeConfigWithDefaults(dataDir string, networkID uint64, opts ...Option)
c.LogMaxBackups = 3 c.LogMaxBackups = 3
c.LogToStderr = true c.LogToStderr = true
c.EnableNTPSync = true c.EnableNTPSync = true
c.WhisperConfig.Enabled = true c.WakuConfig.Enabled = true
for _, opt := range opts { for _, opt := range opts {
if err := opt(c); err != nil { if err := opt(c); err != nil {
@ -666,13 +667,12 @@ func (c *NodeConfig) updatePeerLimits() {
// NewNodeConfig creates new node configuration object with bare-minimum defaults. // NewNodeConfig creates new node configuration object with bare-minimum defaults.
// Important: the returned config is not validated. // Important: the returned config is not validated.
func NewNodeConfig(dataDir string, networkID uint64) (*NodeConfig, error) { func NewNodeConfig(dataDir string, networkID uint64) (*NodeConfig, error) {
var keyStoreDir, wnodeDir string var keyStoreDir, wnodeDir, wakuDir string
if dataDir != "" { if dataDir != "" {
keyStoreDir = filepath.Join(dataDir, "keystore") keyStoreDir = filepath.Join(dataDir, "keystore")
}
if dataDir != "" {
wnodeDir = filepath.Join(dataDir, "wnode") wnodeDir = filepath.Join(dataDir, "wnode")
wakuDir = filepath.Join(dataDir, "waku")
} }
config := &NodeConfig{ config := &NodeConfig{
@ -699,6 +699,12 @@ func NewNodeConfig(dataDir string, networkID uint64) (*NodeConfig, error) {
LightEthConfig: LightEthConfig{ LightEthConfig: LightEthConfig{
DatabaseCache: 16, DatabaseCache: 16,
}, },
WakuConfig: WakuConfig{
DataDir: wakuDir,
MinimumPoW: WakuMinimumPoW,
TTL: WakuTTL,
MaxMessageSize: wakucommon.DefaultMaxMessageSize,
},
WhisperConfig: WhisperConfig{ WhisperConfig: WhisperConfig{
DataDir: wnodeDir, DataDir: wnodeDir,
MinimumPoW: WhisperMinimumPoW, MinimumPoW: WhisperMinimumPoW,
@ -804,6 +810,14 @@ func (c *NodeConfig) Validate() error {
} }
} }
// Waku's data directory must be relative to the main data directory
// if EnableMailServer is true.
if c.WakuConfig.Enabled && c.WakuConfig.EnableMailServer {
if !strings.HasPrefix(c.WakuConfig.DataDir, c.DataDir) {
return fmt.Errorf("WakuConfig.DataDir must start with DataDir fragment")
}
}
if !c.NoDiscovery && len(c.ClusterConfig.BootNodes) == 0 { if !c.NoDiscovery && len(c.ClusterConfig.BootNodes) == 0 {
// No point in running discovery if we don't have bootnodes. // No point in running discovery if we don't have bootnodes.
// In case we do have bootnodes, NoDiscovery should be true. // In case we do have bootnodes, NoDiscovery should be true.