From 186c9d084e6c7561d52542bfce4d00bda6cdb39b Mon Sep 17 00:00:00 2001 From: dreacot Date: Thu, 24 Oct 2024 13:32:23 +0100 Subject: [PATCH] user badgerdb on mobile devices --- libwallet/assets_manager.go | 8 +++++++- main.go | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/libwallet/assets_manager.go b/libwallet/assets_manager.go index 176a9f087..905eec6ae 100644 --- a/libwallet/assets_manager.go +++ b/libwallet/assets_manager.go @@ -38,6 +38,9 @@ const LogFilename = "cryptopower.log" // assetIdentifier use for listen balance of all wallet changed const assetIdentifier = "assets_manager" +const BOLT_DB = "bdb" // Bolt db driver +const BADGER_DB = "badgerdb" // Badger db driver + // Assets is a struct that holds all the assets supported by the wallet. type Assets struct { DCR struct { @@ -139,7 +142,10 @@ func NewAssetsManager(rootDir, logDir string, netType utils.NetworkType, dexTest } // validate the network type before proceeding to initialize the othe fields. - dbDriver := "bdb" // TODO: Should be a constant. + dbDriver := BOLT_DB + if appos.Current().IsMobile() { + dbDriver = BADGER_DB + } mgr, err := initializeAssetsFields(rootDir, dbDriver, logDir, netType, dexTestAddr) if err != nil { return nil, err diff --git a/main.go b/main.go index afbf9a143..d6df90532 100644 --- a/main.go +++ b/main.go @@ -68,7 +68,7 @@ func main() { } else { _ = logger.SetLogLevels(cfg.DebugLevel) } - + assetsManager, err := libwallet.NewAssetsManager(cfg.HomeDir, logDir, netType, cfg.DEXTestAddr) if err != nil { return nil, err