From 685d5b779fc1f6a88f39037c7d6a72fdb0cbb86c Mon Sep 17 00:00:00 2001 From: Guilhem Fanton Date: Fri, 12 Apr 2019 16:20:37 +0200 Subject: [PATCH] fix(bridge): initialize bridge in gomobile --- client/react-native/gomobile/core/bridge.go | 38 +++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/client/react-native/gomobile/core/bridge.go b/client/react-native/gomobile/core/bridge.go index 5020d297b6..d07ee955c0 100644 --- a/client/react-native/gomobile/core/bridge.go +++ b/client/react-native/gomobile/core/bridge.go @@ -6,9 +6,42 @@ import ( "berty.tech/core/api/helper" "berty.tech/core/daemon" + network_config "berty.tech/core/network/config" "google.golang.org/grpc" ) +var sqlConfig = &daemon.SQLConfig{ + Name: "berty.state.db", + Key: "s3cur3", +} + +var config = &daemon.Config{ + SqlOpts: sqlConfig, + GrpcBind: ":0", + GqlBind: ":0", + HideBanner: true, + DropDatabase: false, + InitOnly: false, + WithBot: false, + Notification: true, + ApnsCerts: []string{}, + ApnsDevVoipCerts: []string{}, + FcmAPIKeys: []string{}, + PrivateKeyFile: "", + PeerCache: true, + Identity: "", + Bootstrap: network_config.DefaultBootstrap, + NoP2P: false, + BindP2P: []string{}, + TransportP2P: []string{}, + Hop: false, + Ble: true, + Mdns: true, + DhtServer: false, + PrivateNetwork: true, + SwarmKeyPath: "", +} + type NativeBridge struct { bridge *daemon.Daemon @@ -16,8 +49,13 @@ type NativeBridge struct { conn *grpc.ClientConn } +// @FIXME: NewNativeBridge must not panic, for now Initialize and Dial (should) never +// return an error so it safe, but keep an eye on it. func NewNativeBridge() *NativeBridge { bridge := daemon.New() + if _, err := bridge.Initialize(context.Background(), config); err != nil { + panic(err) + } iogrpc := helper.NewIOGrpc() dialer := iogrpc.NewDialer()