mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-06 17:47:01 +02:00
etcd: add namespace support to separate key spaces
This commit extends etcd db with namespaces without additional storage space requirements. This is simply done by instead of using an all zero root bucket id, we use the sha256 hash of the name space as our root bucket id.
This commit is contained in:
@@ -2,6 +2,7 @@ package lncfg
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"path"
|
||||
|
||||
"github.com/lightningnetwork/lnd/channeldb/kvdb"
|
||||
)
|
||||
@@ -50,12 +51,14 @@ func (db *DB) Validate() error {
|
||||
}
|
||||
|
||||
// GetBackend returns a kvdb.Backend as set in the DB config.
|
||||
func (db *DB) GetBackend(path string) (kvdb.Backend, error) {
|
||||
func (db *DB) GetBackend(dbPath string) (kvdb.Backend, error) {
|
||||
if db.Backend == etcdBackend {
|
||||
return kvdb.GetEtcdBackend(db.Etcd)
|
||||
// Prefix will separate key/values in the db.
|
||||
prefix := path.Join(dbPath, dbName)
|
||||
return kvdb.GetEtcdBackend(prefix, db.Etcd)
|
||||
}
|
||||
|
||||
return kvdb.GetBoltBackend(path, dbName, db.Bolt.NoFreeListSync)
|
||||
return kvdb.GetBoltBackend(dbPath, dbName, db.Bolt.NoFreeListSync)
|
||||
}
|
||||
|
||||
// Compile-time constraint to ensure Workers implements the Validator interface.
|
||||
|
Reference in New Issue
Block a user