Update database import paths to new location.
This commit is contained in:
parent
8d7780e0ab
commit
309a9ea31d
18 changed files with 81 additions and 80 deletions
|
@ -14,7 +14,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/btcsuite/btcchain"
|
||||
"github.com/btcsuite/btcdb"
|
||||
"github.com/btcsuite/btcd/database"
|
||||
"github.com/btcsuite/btcnet"
|
||||
"github.com/btcsuite/btcutil"
|
||||
"github.com/btcsuite/btcwire"
|
||||
|
@ -1456,13 +1456,13 @@ func warnMultipeDBs() {
|
|||
// such warning the user if there are multiple databases which consume space on
|
||||
// the file system and ensuring the regression test database is clean when in
|
||||
// regression test mode.
|
||||
func setupBlockDB() (btcdb.Db, error) {
|
||||
func setupBlockDB() (database.Db, error) {
|
||||
// The memdb backend does not have a file path associated with it, so
|
||||
// handle it uniquely. We also don't want to worry about the multiple
|
||||
// database type warnings when running with the memory database.
|
||||
if cfg.DbType == "memdb" {
|
||||
btcdLog.Infof("Creating block database in memory.")
|
||||
db, err := btcdb.CreateDB(cfg.DbType)
|
||||
db, err := database.CreateDB(cfg.DbType)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -1479,11 +1479,11 @@ func setupBlockDB() (btcdb.Db, error) {
|
|||
removeRegressionDB(dbPath)
|
||||
|
||||
btcdLog.Infof("Loading block database from '%s'", dbPath)
|
||||
db, err := btcdb.OpenDB(cfg.DbType, dbPath)
|
||||
db, err := database.OpenDB(cfg.DbType, dbPath)
|
||||
if err != nil {
|
||||
// Return the error if it's not because the database
|
||||
// doesn't exist.
|
||||
if err != btcdb.ErrDbDoesNotExist {
|
||||
if err != database.ErrDbDoesNotExist {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
@ -1492,7 +1492,7 @@ func setupBlockDB() (btcdb.Db, error) {
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
db, err = btcdb.CreateDB(cfg.DbType, dbPath)
|
||||
db, err = database.CreateDB(cfg.DbType, dbPath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -1502,7 +1502,7 @@ func setupBlockDB() (btcdb.Db, error) {
|
|||
}
|
||||
|
||||
// loadBlockDB opens the block database and returns a handle to it.
|
||||
func loadBlockDB() (btcdb.Db, error) {
|
||||
func loadBlockDB() (database.Db, error) {
|
||||
db, err := setupBlockDB()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
@ -10,9 +10,9 @@ import (
|
|||
"runtime"
|
||||
|
||||
"github.com/btcsuite/btcchain"
|
||||
"github.com/btcsuite/btcd/database"
|
||||
_ "github.com/btcsuite/btcd/database/ldb"
|
||||
"github.com/btcsuite/btcd/limits"
|
||||
"github.com/btcsuite/btcdb"
|
||||
_ "github.com/btcsuite/btcdb/ldb"
|
||||
"github.com/btcsuite/btclog"
|
||||
)
|
||||
|
||||
|
@ -27,7 +27,7 @@ var (
|
|||
)
|
||||
|
||||
// loadBlockDB opens the block database and returns a handle to it.
|
||||
func loadBlockDB() (btcdb.Db, error) {
|
||||
func loadBlockDB() (database.Db, error) {
|
||||
// The database name is based on the database type.
|
||||
dbName := blockDbNamePrefix + "_" + cfg.DbType
|
||||
if cfg.DbType == "sqlite" {
|
||||
|
@ -36,11 +36,11 @@ func loadBlockDB() (btcdb.Db, error) {
|
|||
dbPath := filepath.Join(cfg.DataDir, dbName)
|
||||
|
||||
log.Infof("Loading block database from '%s'", dbPath)
|
||||
db, err := btcdb.OpenDB(cfg.DbType, dbPath)
|
||||
db, err := database.OpenDB(cfg.DbType, dbPath)
|
||||
if err != nil {
|
||||
// Return the error if it's not because the database doesn't
|
||||
// exist.
|
||||
if err != btcdb.ErrDbDoesNotExist {
|
||||
if err != database.ErrDbDoesNotExist {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,7 @@ func loadBlockDB() (btcdb.Db, error) {
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
db, err = btcdb.CreateDB(cfg.DbType, dbPath)
|
||||
db, err = database.CreateDB(cfg.DbType, dbPath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ func realMain() error {
|
|||
backendLogger := btclog.NewDefaultBackendLogger()
|
||||
defer backendLogger.Flush()
|
||||
log = btclog.NewSubsystemLogger(backendLogger, "")
|
||||
btcdb.UseLogger(btclog.NewSubsystemLogger(backendLogger, "BCDB: "))
|
||||
database.UseLogger(btclog.NewSubsystemLogger(backendLogger, "BCDB: "))
|
||||
btcchain.UseLogger(btclog.NewSubsystemLogger(backendLogger, "CHAN: "))
|
||||
|
||||
// Load the block database.
|
||||
|
|
|
@ -9,8 +9,8 @@ import (
|
|||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/btcsuite/btcdb"
|
||||
_ "github.com/btcsuite/btcdb/ldb"
|
||||
"github.com/btcsuite/btcd/database"
|
||||
_ "github.com/btcsuite/btcd/database/ldb"
|
||||
"github.com/btcsuite/btcnet"
|
||||
"github.com/btcsuite/btcutil"
|
||||
"github.com/btcsuite/btcwire"
|
||||
|
@ -26,7 +26,7 @@ const (
|
|||
var (
|
||||
btcdHomeDir = btcutil.AppDataDir("btcd", false)
|
||||
defaultDataDir = filepath.Join(btcdHomeDir, "data")
|
||||
knownDbTypes = btcdb.SupportedDBs()
|
||||
knownDbTypes = database.SupportedDBs()
|
||||
activeNetParams = &btcnet.MainNetParams
|
||||
)
|
||||
|
||||
|
|
|
@ -12,8 +12,8 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/btcsuite/btcchain"
|
||||
"github.com/btcsuite/btcdb"
|
||||
_ "github.com/btcsuite/btcdb/ldb"
|
||||
"github.com/btcsuite/btcd/database"
|
||||
_ "github.com/btcsuite/btcd/database/ldb"
|
||||
"github.com/btcsuite/btcutil"
|
||||
"github.com/btcsuite/btcwire"
|
||||
)
|
||||
|
@ -30,7 +30,7 @@ type importResults struct {
|
|||
// blockImporter houses information about an ongoing import from a block data
|
||||
// file to the block database.
|
||||
type blockImporter struct {
|
||||
db btcdb.Db
|
||||
db database.Db
|
||||
chain *btcchain.BlockChain
|
||||
medianTime btcchain.MedianTimeSource
|
||||
r io.ReadSeeker
|
||||
|
@ -299,7 +299,7 @@ func (bi *blockImporter) Import() chan *importResults {
|
|||
|
||||
// newBlockImporter returns a new importer for the provided file reader seeker
|
||||
// and database.
|
||||
func newBlockImporter(db btcdb.Db, r io.ReadSeeker) *blockImporter {
|
||||
func newBlockImporter(db database.Db, r io.ReadSeeker) *blockImporter {
|
||||
return &blockImporter{
|
||||
db: db,
|
||||
r: r,
|
||||
|
|
|
@ -11,8 +11,8 @@ import (
|
|||
"path/filepath"
|
||||
"strconv"
|
||||
|
||||
"github.com/btcsuite/btcdb"
|
||||
_ "github.com/btcsuite/btcdb/ldb"
|
||||
"github.com/btcsuite/btcd/database"
|
||||
_ "github.com/btcsuite/btcd/database/ldb"
|
||||
"github.com/btcsuite/btclog"
|
||||
"github.com/btcsuite/btcnet"
|
||||
"github.com/btcsuite/btcutil"
|
||||
|
@ -78,7 +78,7 @@ func main() {
|
|||
backendLogger := btclog.NewDefaultBackendLogger()
|
||||
defer backendLogger.Flush()
|
||||
log = btclog.NewSubsystemLogger(backendLogger, "")
|
||||
btcdb.UseLogger(log)
|
||||
database.UseLogger(log)
|
||||
|
||||
// Multiple networks can't be selected simultaneously.
|
||||
funcName := "main"
|
||||
|
@ -115,7 +115,7 @@ func main() {
|
|||
dbPath := filepath.Join(cfg.DataDir, dbName)
|
||||
|
||||
log.Infof("loading db")
|
||||
db, err := btcdb.OpenDB(cfg.DbType, dbPath)
|
||||
db, err := database.OpenDB(cfg.DbType, dbPath)
|
||||
if err != nil {
|
||||
log.Warnf("db open failed: %v", err)
|
||||
return
|
||||
|
@ -139,7 +139,7 @@ func main() {
|
|||
|
||||
}
|
||||
|
||||
func getSha(db btcdb.Db, str string) (btcwire.ShaHash, error) {
|
||||
func getSha(db database.Db, str string) (btcwire.ShaHash, error) {
|
||||
argtype, idx, sha, err := parsesha(str)
|
||||
if err != nil {
|
||||
log.Warnf("unable to decode [%v] %v", str, err)
|
||||
|
|
|
@ -9,8 +9,8 @@ import (
|
|||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/btcsuite/btcdb"
|
||||
_ "github.com/btcsuite/btcdb/ldb"
|
||||
"github.com/btcsuite/btcd/database"
|
||||
_ "github.com/btcsuite/btcd/database/ldb"
|
||||
"github.com/btcsuite/btcnet"
|
||||
"github.com/btcsuite/btcutil"
|
||||
"github.com/btcsuite/btcwire"
|
||||
|
@ -27,7 +27,7 @@ const (
|
|||
var (
|
||||
btcdHomeDir = btcutil.AppDataDir("btcd", false)
|
||||
defaultDataDir = filepath.Join(btcdHomeDir, "data")
|
||||
knownDbTypes = btcdb.SupportedDBs()
|
||||
knownDbTypes = database.SupportedDBs()
|
||||
activeNetParams = &btcnet.MainNetParams
|
||||
)
|
||||
|
||||
|
|
|
@ -10,8 +10,8 @@ import (
|
|||
"path/filepath"
|
||||
|
||||
"github.com/btcsuite/btcchain"
|
||||
"github.com/btcsuite/btcdb"
|
||||
_ "github.com/btcsuite/btcdb/ldb"
|
||||
"github.com/btcsuite/btcd/database"
|
||||
_ "github.com/btcsuite/btcd/database/ldb"
|
||||
"github.com/btcsuite/btcnet"
|
||||
"github.com/btcsuite/btcwire"
|
||||
)
|
||||
|
@ -23,7 +23,7 @@ var (
|
|||
)
|
||||
|
||||
// loadBlockDB opens the block database and returns a handle to it.
|
||||
func loadBlockDB() (btcdb.Db, error) {
|
||||
func loadBlockDB() (database.Db, error) {
|
||||
// The database name is based on the database type.
|
||||
dbType := cfg.DbType
|
||||
dbName := blockDbNamePrefix + "_" + dbType
|
||||
|
@ -32,7 +32,7 @@ func loadBlockDB() (btcdb.Db, error) {
|
|||
}
|
||||
dbPath := filepath.Join(cfg.DataDir, dbName)
|
||||
fmt.Printf("Loading block database from '%s'\n", dbPath)
|
||||
db, err := btcdb.OpenDB(dbType, dbPath)
|
||||
db, err := database.OpenDB(dbType, dbPath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ func loadBlockDB() (btcdb.Db, error) {
|
|||
// candidates at the last checkpoint that is already hard coded into btcchain
|
||||
// since there is no point in finding candidates before already existing
|
||||
// checkpoints.
|
||||
func findCandidates(db btcdb.Db, latestHash *btcwire.ShaHash) ([]*btcnet.Checkpoint, error) {
|
||||
func findCandidates(db database.Db, latestHash *btcwire.ShaHash) ([]*btcnet.Checkpoint, error) {
|
||||
// Start with the latest block of the main chain.
|
||||
block, err := db.FetchBlockBySha(latestHash)
|
||||
if err != nil {
|
||||
|
|
|
@ -13,8 +13,8 @@ import (
|
|||
"path/filepath"
|
||||
"strconv"
|
||||
|
||||
"github.com/btcsuite/btcdb"
|
||||
_ "github.com/btcsuite/btcdb/ldb"
|
||||
"github.com/btcsuite/btcd/database"
|
||||
_ "github.com/btcsuite/btcd/database/ldb"
|
||||
"github.com/btcsuite/btclog"
|
||||
"github.com/btcsuite/btcnet"
|
||||
"github.com/btcsuite/btcutil"
|
||||
|
@ -89,7 +89,7 @@ func main() {
|
|||
backendLogger := btclog.NewDefaultBackendLogger()
|
||||
defer backendLogger.Flush()
|
||||
log = btclog.NewSubsystemLogger(backendLogger, "")
|
||||
btcdb.UseLogger(log)
|
||||
database.UseLogger(log)
|
||||
|
||||
// Multiple networks can't be selected simultaneously.
|
||||
funcName := "main"
|
||||
|
@ -126,7 +126,7 @@ func main() {
|
|||
dbPath := filepath.Join(cfg.DataDir, dbName)
|
||||
|
||||
log.Infof("loading db %v", cfg.DbType)
|
||||
db, err := btcdb.OpenDB(cfg.DbType, dbPath)
|
||||
db, err := database.OpenDB(cfg.DbType, dbPath)
|
||||
if err != nil {
|
||||
log.Warnf("db open failed: %v", err)
|
||||
return
|
||||
|
@ -179,7 +179,7 @@ func main() {
|
|||
}
|
||||
}
|
||||
|
||||
func getHeight(db btcdb.Db, str string) (int64, error) {
|
||||
func getHeight(db database.Db, str string) (int64, error) {
|
||||
argtype, idx, sha, err := parsesha(str)
|
||||
if err != nil {
|
||||
log.Warnf("unable to decode [%v] %v", str, err)
|
||||
|
@ -201,7 +201,7 @@ func getHeight(db btcdb.Db, str string) (int64, error) {
|
|||
return idx, nil
|
||||
}
|
||||
|
||||
func DumpBlock(db btcdb.Db, height int64, fo io.Writer, rflag bool, fflag bool, tflag bool) error {
|
||||
func DumpBlock(db database.Db, height int64, fo io.Writer, rflag bool, fflag bool, tflag bool) error {
|
||||
sha, err := db.FetchBlockShaByHeight(height)
|
||||
|
||||
if err != nil {
|
||||
|
|
|
@ -16,9 +16,9 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/btcsuite/btcdb"
|
||||
_ "github.com/btcsuite/btcdb/ldb"
|
||||
_ "github.com/btcsuite/btcdb/memdb"
|
||||
"github.com/btcsuite/btcd/database"
|
||||
_ "github.com/btcsuite/btcd/database/ldb"
|
||||
_ "github.com/btcsuite/btcd/database/memdb"
|
||||
"github.com/btcsuite/btcutil"
|
||||
"github.com/btcsuite/btcwire"
|
||||
flags "github.com/btcsuite/go-flags"
|
||||
|
@ -50,7 +50,7 @@ var (
|
|||
btcdHomeDir = btcutil.AppDataDir("btcd", false)
|
||||
defaultConfigFile = filepath.Join(btcdHomeDir, defaultConfigFilename)
|
||||
defaultDataDir = filepath.Join(btcdHomeDir, defaultDataDirname)
|
||||
knownDbTypes = btcdb.SupportedDBs()
|
||||
knownDbTypes = database.SupportedDBs()
|
||||
defaultRPCKeyFile = filepath.Join(btcdHomeDir, "rpc.key")
|
||||
defaultRPCCertFile = filepath.Join(btcdHomeDir, "rpc.cert")
|
||||
defaultLogDir = filepath.Join(btcdHomeDir, defaultLogDirname)
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
"bytes"
|
||||
"compress/bzip2"
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
@ -36,9 +35,8 @@ type testDb struct {
|
|||
cleanUpFunc func()
|
||||
}
|
||||
|
||||
func setUpTestDb(t *testing.T) (*testDb, error) {
|
||||
func setUpTestDb(t *testing.T, dbname string) (*testDb, error) {
|
||||
// Ignore db remove errors since it means we didn't have an old one.
|
||||
dbname := fmt.Sprintf("tstdbop1")
|
||||
dbnamever := dbname + ".ver"
|
||||
_ = os.RemoveAll(dbname)
|
||||
_ = os.RemoveAll(dbnamever)
|
||||
|
@ -160,7 +158,7 @@ func testAddrIndexOperations(t *testing.T, db database.Db, newestBlock *btcutil.
|
|||
db.Close()
|
||||
|
||||
// Re-Open, tip still should be updated to current height and sha.
|
||||
db, err = database.OpenDB("leveldb", "tstdbop1")
|
||||
db, err = database.OpenDB("leveldb", "tstdbopmode")
|
||||
if err != nil {
|
||||
t.Fatalf("Unable to re-open created db, err %v", err)
|
||||
}
|
||||
|
@ -209,12 +207,12 @@ func testOperationalMode(t *testing.T) {
|
|||
// 2) look up all txin (except coinbase in db)
|
||||
// 3) insert block
|
||||
// 4) exercise the optional addridex
|
||||
testDb, err := setUpTestDb(t)
|
||||
defer testDb.cleanUpFunc()
|
||||
testDb, err := setUpTestDb(t, "tstdbopmode")
|
||||
if err != nil {
|
||||
t.Errorf("Unable to load blocks from test data: %v", err)
|
||||
t.Errorf("Failed to open test database %v", err)
|
||||
return
|
||||
}
|
||||
defer testDb.cleanUpFunc()
|
||||
err = nil
|
||||
out:
|
||||
for height := int64(0); height < int64(len(testDb.blocks)); height++ {
|
||||
|
@ -295,13 +293,12 @@ func testBackout(t *testing.T) {
|
|||
// 2) look up all txin (except coinbase in db)
|
||||
// 3) insert block
|
||||
|
||||
testDb, err := setUpTestDb(t)
|
||||
defer testDb.cleanUpFunc()
|
||||
|
||||
testDb, err := setUpTestDb(t, "tstdbbackout")
|
||||
if err != nil {
|
||||
t.Errorf("Failed to open test database %v", err)
|
||||
return
|
||||
}
|
||||
defer testDb.cleanUpFunc()
|
||||
|
||||
if len(testDb.blocks) < 120 {
|
||||
t.Errorf("test data too small")
|
||||
|
@ -516,7 +513,11 @@ func testFetchHeightRange(t *testing.T, db database.Db, blocks []*btcutil.Block)
|
|||
}
|
||||
|
||||
func TestLimitAndSkipFetchTxsForAddr(t *testing.T) {
|
||||
testDb, err := setUpTestDb(t)
|
||||
testDb, err := setUpTestDb(t, "tstdbtxaddr")
|
||||
if err != nil {
|
||||
t.Errorf("Failed to open test database %v", err)
|
||||
return
|
||||
}
|
||||
defer testDb.cleanUpFunc()
|
||||
|
||||
// Insert a block with some fake test transactions. The block will have
|
||||
|
|
|
@ -202,8 +202,8 @@ information.
|
|||
* [btcscript](https://github.com/btcsuite/btcscript) - Implements the
|
||||
Bitcoin transaction scripting language
|
||||
* [btcec](https://github.com/btcsuite/btcec) - Implements support for the
|
||||
elliptic curve cryptographic functions needed for the Bitcoin scripts
|
||||
* [btcdb](https://github.com/btcsuite/btcdb) - Provides a database interface
|
||||
for the Bitcoin block chain
|
||||
* [database](https://github.com/btcsuite/btcd/tree/master/database) -
|
||||
Provides a database interface elliptic curve cryptographic functions
|
||||
needed for the Bitcoin scripts for the Bitcoin block chain
|
||||
* [btcutil](https://github.com/btcsuite/btcutil) - Provides Bitcoin-specific
|
||||
convenience functions and types
|
4
log.go
4
log.go
|
@ -13,7 +13,7 @@ import (
|
|||
"github.com/btcsuite/btcd/addrmgr"
|
||||
|
||||
"github.com/btcsuite/btcchain"
|
||||
"github.com/btcsuite/btcdb"
|
||||
"github.com/btcsuite/btcd/database"
|
||||
"github.com/btcsuite/btclog"
|
||||
"github.com/btcsuite/btcscript"
|
||||
"github.com/btcsuite/btcwire"
|
||||
|
@ -100,7 +100,7 @@ func useLogger(subsystemID string, logger btclog.Logger) {
|
|||
|
||||
case "BCDB":
|
||||
bcdbLog = logger
|
||||
btcdb.UseLogger(logger)
|
||||
database.UseLogger(logger)
|
||||
|
||||
case "BMGR":
|
||||
bmgrLog = logger
|
||||
|
|
|
@ -14,7 +14,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/btcsuite/btcchain"
|
||||
"github.com/btcsuite/btcdb"
|
||||
"github.com/btcsuite/btcd/database"
|
||||
"github.com/btcsuite/btcscript"
|
||||
"github.com/btcsuite/btcutil"
|
||||
"github.com/btcsuite/btcwire"
|
||||
|
@ -764,7 +764,7 @@ func (mp *txMemPool) fetchInputTransactions(tx *btcutil.Tx) (btcchain.TxStore, e
|
|||
|
||||
// Attempt to populate any missing inputs from the transaction pool.
|
||||
for _, txD := range txStore {
|
||||
if txD.Err == btcdb.ErrTxShaMissing || txD.Tx == nil {
|
||||
if txD.Err == database.ErrTxShaMissing || txD.Tx == nil {
|
||||
if poolTxDesc, exists := mp.pool[*txD.Hash]; exists {
|
||||
poolTx := poolTxDesc.Tx
|
||||
txD.Tx = poolTx
|
||||
|
@ -911,7 +911,7 @@ func (mp *txMemPool) maybeAcceptTransaction(tx *btcutil.Tx, isNew, rateLimit boo
|
|||
// behavior is desired.
|
||||
var missingParents []*btcwire.ShaHash
|
||||
for _, txD := range txStore {
|
||||
if txD.Err == btcdb.ErrTxShaMissing {
|
||||
if txD.Err == database.ErrTxShaMissing {
|
||||
missingParents = append(missingParents, txD.Hash)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/btcsuite/btcchain"
|
||||
"github.com/btcsuite/btcdb"
|
||||
"github.com/btcsuite/btcd/database"
|
||||
"github.com/btcsuite/btcscript"
|
||||
"github.com/btcsuite/btcutil"
|
||||
"github.com/btcsuite/btcwire"
|
||||
|
@ -188,8 +188,8 @@ func minInt(a, b int) int {
|
|||
func mergeTxStore(txStoreA btcchain.TxStore, txStoreB btcchain.TxStore) {
|
||||
for hash, txDataB := range txStoreB {
|
||||
if txDataA, exists := txStoreA[hash]; !exists ||
|
||||
(txDataA.Err == btcdb.ErrTxShaMissing && txDataB.Err !=
|
||||
btcdb.ErrTxShaMissing) {
|
||||
(txDataA.Err == database.ErrTxShaMissing &&
|
||||
txDataB.Err != database.ErrTxShaMissing) {
|
||||
|
||||
txStoreA[hash] = txDataB
|
||||
}
|
||||
|
|
8
peer.go
8
peer.go
|
@ -18,7 +18,7 @@ import (
|
|||
|
||||
"github.com/btcsuite/btcchain"
|
||||
"github.com/btcsuite/btcd/addrmgr"
|
||||
"github.com/btcsuite/btcdb"
|
||||
"github.com/btcsuite/btcd/database"
|
||||
"github.com/btcsuite/btcutil"
|
||||
"github.com/btcsuite/btcutil/bloom"
|
||||
"github.com/btcsuite/btcwire"
|
||||
|
@ -890,7 +890,7 @@ func (p *peer) handleGetBlocksMsg(msg *btcwire.MsgGetBlocks) {
|
|||
// Return all block hashes to the latest one (up to max per message) if
|
||||
// no stop hash was specified.
|
||||
// Attempt to find the ending index of the stop hash if specified.
|
||||
endIdx := btcdb.AllShas
|
||||
endIdx := database.AllShas
|
||||
if !msg.HashStop.IsEqual(&zeroHash) {
|
||||
height, err := p.server.db.FetchBlockHeightBySha(&msg.HashStop)
|
||||
if err == nil {
|
||||
|
@ -969,7 +969,7 @@ func (p *peer) handleGetBlocksMsg(msg *btcwire.MsgGetBlocks) {
|
|||
// message.
|
||||
func (p *peer) handleGetHeadersMsg(msg *btcwire.MsgGetHeaders) {
|
||||
// Attempt to look up the height of the provided stop hash.
|
||||
endIdx := btcdb.AllShas
|
||||
endIdx := database.AllShas
|
||||
height, err := p.server.db.FetchBlockHeightBySha(&msg.HashStop)
|
||||
if err == nil {
|
||||
endIdx = height + 1
|
||||
|
@ -981,7 +981,7 @@ func (p *peer) handleGetHeadersMsg(msg *btcwire.MsgGetHeaders) {
|
|||
// No blocks with the stop hash were found so there is nothing
|
||||
// to do. Just return. This behavior mirrors the reference
|
||||
// implementation.
|
||||
if endIdx == btcdb.AllShas {
|
||||
if endIdx == database.AllShas {
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/btcsuite/btcchain"
|
||||
"github.com/btcsuite/btcdb"
|
||||
"github.com/btcsuite/btcd/database"
|
||||
"github.com/btcsuite/btcec"
|
||||
"github.com/btcsuite/btcjson"
|
||||
"github.com/btcsuite/btcnet"
|
||||
|
@ -3068,7 +3068,7 @@ func handleSubmitBlock(s *rpcServer, cmd btcjson.Cmd, closeChan <-chan struct{})
|
|||
return nil, nil
|
||||
}
|
||||
|
||||
func verifyChain(db btcdb.Db, level, depth int32, timeSource btcchain.MedianTimeSource) error {
|
||||
func verifyChain(db database.Db, level, depth int32, timeSource btcchain.MedianTimeSource) error {
|
||||
_, curHeight64, err := db.NewestSha()
|
||||
if err != nil {
|
||||
rpcsLog.Errorf("Verify is unable to fetch current block "+
|
||||
|
|
|
@ -19,7 +19,7 @@ import (
|
|||
|
||||
"golang.org/x/crypto/ripemd160"
|
||||
|
||||
"github.com/btcsuite/btcdb"
|
||||
"github.com/btcsuite/btcd/database"
|
||||
"github.com/btcsuite/btcjson"
|
||||
"github.com/btcsuite/btcscript"
|
||||
"github.com/btcsuite/btcutil"
|
||||
|
@ -1607,7 +1607,7 @@ func rescanBlock(wsc *wsClient, lookups *rescanKeys, blk *btcutil.Block) {
|
|||
// verifies that the new range of blocks is on the same fork as a previous
|
||||
// range of blocks. If this condition does not hold true, the JSON-RPC error
|
||||
// for an unrecoverable reorganize is returned.
|
||||
func recoverFromReorg(db btcdb.Db, minBlock, maxBlock int64,
|
||||
func recoverFromReorg(db database.Db, minBlock, maxBlock int64,
|
||||
lastBlock *btcutil.Block) ([]btcwire.ShaHash, *btcjson.Error) {
|
||||
|
||||
hashList, err := db.FetchHeightRange(minBlock, maxBlock)
|
||||
|
@ -1753,7 +1753,7 @@ func handleRescan(wsc *wsClient, icmd btcjson.Cmd) (interface{}, *btcjson.Error)
|
|||
return nil, &btcjson.ErrBlockNotFound
|
||||
}
|
||||
|
||||
maxBlock := btcdb.AllShas
|
||||
maxBlock := database.AllShas
|
||||
if cmd.EndBlock != "" {
|
||||
maxBlockSha, err := btcwire.NewShaHashFromStr(cmd.EndBlock)
|
||||
if err != nil {
|
||||
|
@ -1791,7 +1791,7 @@ fetchRange:
|
|||
if err != nil {
|
||||
// Only handle reorgs if a block could not be
|
||||
// found for the hash.
|
||||
if err != btcdb.ErrBlockShaMissing {
|
||||
if err != database.ErrBlockShaMissing {
|
||||
rpcsLog.Errorf("Error looking up "+
|
||||
"block: %v", err)
|
||||
return nil, &btcjson.ErrDatabase
|
||||
|
@ -1799,7 +1799,7 @@ fetchRange:
|
|||
|
||||
// If an absolute max block was specified, don't
|
||||
// attempt to handle the reorg.
|
||||
if maxBlock != btcdb.AllShas {
|
||||
if maxBlock != database.AllShas {
|
||||
rpcsLog.Errorf("Stopping rescan for "+
|
||||
"reorged block %v",
|
||||
cmd.EndBlock)
|
||||
|
|
|
@ -21,7 +21,7 @@ import (
|
|||
|
||||
"github.com/btcsuite/btcchain"
|
||||
"github.com/btcsuite/btcd/addrmgr"
|
||||
"github.com/btcsuite/btcdb"
|
||||
"github.com/btcsuite/btcd/database"
|
||||
"github.com/btcsuite/btcjson"
|
||||
"github.com/btcsuite/btcnet"
|
||||
"github.com/btcsuite/btcwire"
|
||||
|
@ -90,7 +90,7 @@ type server struct {
|
|||
wg sync.WaitGroup
|
||||
quit chan struct{}
|
||||
nat NAT
|
||||
db btcdb.Db
|
||||
db database.Db
|
||||
timeSource btcchain.MedianTimeSource
|
||||
}
|
||||
|
||||
|
@ -1083,7 +1083,7 @@ out:
|
|||
// newServer returns a new btcd server configured to listen on addr for the
|
||||
// bitcoin network type specified by netParams. Use start to begin accepting
|
||||
// connections from peers.
|
||||
func newServer(listenAddrs []string, db btcdb.Db, netParams *btcnet.Params) (*server, error) {
|
||||
func newServer(listenAddrs []string, db database.Db, netParams *btcnet.Params) (*server, error) {
|
||||
nonce, err := btcwire.RandomUint64()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
Loading…
Add table
Reference in a new issue