Skip to content

Commit

Permalink
fix(core): fix transport start flag
Browse files Browse the repository at this point in the history
Signed-off-by: Sacha Froment <sfroment42@gmail.com>
  • Loading branch information
sfroment committed Oct 23, 2018
1 parent 98cc090 commit 92ad4d0
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
1 change: 1 addition & 0 deletions core/cmd/berty/daemon.go
Expand Up @@ -93,6 +93,7 @@ func daemon(opts *daemonOptions) error {
accountOptions = append(accountOptions, account.WithP2PNetwork(
&account.P2PNetworkOptions{
Bind: opts.bindP2P,
Transport: opts.transportP2P,
Bootstrap: opts.bootstrap,
MDNS: opts.mdns,
Relay: opts.hop,
Expand Down
3 changes: 0 additions & 3 deletions core/manager/account/account.go
Expand Up @@ -88,9 +88,6 @@ func (a *Account) Validate() error {
}

func (a *Account) Open() error {
if err := a.openDatabase(); err != nil {
return err
}
if err := a.initNode(); err != nil {
return err
}
Expand Down
3 changes: 3 additions & 0 deletions core/manager/account/options.go
Expand Up @@ -65,6 +65,9 @@ func WithDatabase(opts *DatabaseOptions) NewOption {
}

a.dbDrop = opts.Drop
if err := a.openDatabase(); err != nil {
return err
}
return nil
}
}
Expand Down
11 changes: 10 additions & 1 deletion core/manager/account/p2p.go
Expand Up @@ -11,6 +11,7 @@ import (

type P2PNetworkOptions struct {
Bind []string
Transport []string
Bootstrap []string
DefaultBootstrap bool
MDNS bool
Expand Down Expand Up @@ -61,11 +62,19 @@ func WithP2PNetwork(opts *P2PNetworkOptions) NewOption {
identity = p2p.WithIdentity(prvKey)
}

for _, v := range opts.Transport {
switch v {
case "default":
p2pOptions = append(p2pOptions, p2p.WithDefaultTransports())
case "ble":
p2pOptions = append(p2pOptions, p2p.WithTransportBle(opts.Bind, a.db))
}
}

p2pOptions = append(p2pOptions,
p2p.WithDefaultMuxers(),
p2p.WithDefaultPeerstore(),
p2p.WithDefaultSecurity(),
p2p.WithDefaultTransports(),
// @TODO: Allow static identity loaded from a file (useful for relay
// server for creating static endpoint for bootstrap)
// p2p.WithIdentity(<key>),
Expand Down

0 comments on commit 92ad4d0

Please sign in to comment.