-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3d91bb6
commit 74b9c9c
Showing
16 changed files
with
374 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
//go:build !kvdb_sqlite || (windows && (arm || 386)) || (linux && (ppc64 || mips || mipsle || mips64)) | ||
|
||
package kvdb | ||
|
||
import ( | ||
"fmt" | ||
"runtime" | ||
|
||
"github.com/btcsuite/btcwallet/walletdb" | ||
) | ||
|
||
var errSqliteNotAvailable = fmt.Errorf("sqlite backend not available either "+ | ||
"due to the `kvdb_sqlite` build tag not being set, or due to this "+ | ||
"OS(%s) and/or architecture(%s) not being supported", runtime.GOOS, | ||
runtime.GOARCH) | ||
|
||
// SqliteBackend is conditionally set to false when the kvdb_sqlite build tag is | ||
// not defined. This will allow testing of other database backends. | ||
const SqliteBackend = false | ||
|
||
// StartSqliteTestBackend is a stub returning nil, and errSqliteNotAvailable | ||
// error. | ||
func StartSqliteTestBackend(path, name, table string) (walletdb.DB, error) { | ||
return nil, errSqliteNotAvailable | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
//go:build kvdb_sqlite && !(windows && (arm || 386)) && !(linux && (ppc64 || mips || mipsle || mips64)) | ||
|
||
package kvdb | ||
|
||
import ( | ||
"context" | ||
"os" | ||
"time" | ||
|
||
"github.com/btcsuite/btcwallet/walletdb" | ||
"github.com/lightningnetwork/lnd/kvdb/sqlbase" | ||
"github.com/lightningnetwork/lnd/kvdb/sqlite" | ||
) | ||
|
||
const ( | ||
// SqliteBackend is conditionally set to true when the kvdb_sqlite build | ||
// tag is defined. This will allow testing of other database backends. | ||
SqliteBackend = true | ||
|
||
testMaxConnections = 50 | ||
) | ||
|
||
// StartSqliteTestBackend starts a sqlite backed wallet.DB instance | ||
func StartSqliteTestBackend(path, name, table string) (walletdb.DB, error) { | ||
if !fileExists(path) { | ||
err := os.Mkdir(path, 0700) | ||
if err != nil { | ||
return nil, err | ||
} | ||
} | ||
|
||
sqlbase.Init(testMaxConnections) | ||
return sqlite.NewSqliteBackend( | ||
context.Background(), &sqlite.Config{ | ||
Timeout: time.Second * 30, | ||
BusyTimeout: time.Second * 5, | ||
}, path, name, table, | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package sqlite | ||
|
||
import "time" | ||
|
||
// Config holds sqlite configuration data. | ||
// | ||
//nolint:lll | ||
type Config struct { | ||
Timeout time.Duration `long:"timeout" description:"The time after which a database query should be timed out."` | ||
BusyTimeout time.Duration `long:"busytimeout" description:"The maximum amount of time to wait for a database connection to become available for a query."` | ||
MaxConnections int `long:"maxconnections" description:"The maximum number of open connections to the database. Set to zero for unlimited."` | ||
PragmaOptions []string `long:"pragmaoptions" description:"A list of pragma options to set on a database connection. For example, 'auto_vacuum=incremental'. Note that the flag must be specified multiple times if multiple options are to be set."` | ||
} |
Oops, something went wrong.