lncfg: add new GetBackends which returns active DB backends

In this commit, we modify the existing `GetBackend` method to now be
called `GetBackends`. This new method will populate a new `RemoteDB`
attribute based on if the replicated backend is active or not. As is,
the local backend is used everywhere. An upcoming commit will once again
re-enable the remote backend, in a hybrid manner.
This commit is contained in:
Olaoluwa Osuntokun
2020-05-06 20:48:05 -07:00
parent 6a6521bba0
commit 7355c8ba3a
2 changed files with 43 additions and 10 deletions

7
lnd.go
View File

@@ -251,6 +251,7 @@ func Main(cfg *Config, lisCfg ListenerCfg, shutdownChan <-chan struct{}) error {
"minutes...")
startOpenTime := time.Now()
ctx := context.Background()
ctx, cancel := context.WithCancel(ctx)
defer cancel()
@@ -260,8 +261,8 @@ func Main(cfg *Config, lisCfg ListenerCfg, shutdownChan <-chan struct{}) error {
cfg.DB.Bolt.SyncFreelist)
}
chanDbBackend, err := cfg.DB.GetBackend(ctx,
cfg.localDatabaseDir(), cfg.networkName(),
databaseBackends, err := cfg.DB.GetBackends(
ctx, cfg.localDatabaseDir(), cfg.networkName(),
)
if err != nil {
ltndLog.Error(err)
@@ -271,7 +272,7 @@ func Main(cfg *Config, lisCfg ListenerCfg, shutdownChan <-chan struct{}) error {
// Open the channeldb, which is dedicated to storing channel, and
// network related metadata.
chanDB, err := channeldb.CreateWithBackend(
chanDbBackend,
databaseBackends.LocalDB,
channeldb.OptionSetRejectCacheSize(cfg.Caches.RejectCacheSize),
channeldb.OptionSetChannelCacheSize(cfg.Caches.ChannelCacheSize),
channeldb.OptionDryRunMigration(cfg.DryRunMigration),