From dd512e7315f5e2ecdd65bd338dc645a6bca86a36 Mon Sep 17 00:00:00 2001 From: Dave Collins Date: Tue, 27 Jan 2015 15:00:49 -0600 Subject: [PATCH] Update database import paths to new location. --- chain.go | 6 +++--- common_test.go | 14 +++++++------- example_test.go | 6 +++--- txlookup.go | 10 +++++----- validate.go | 4 ++-- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/chain.go b/chain.go index e0333770..c356ee3e 100644 --- a/chain.go +++ b/chain.go @@ -13,7 +13,7 @@ import ( "sync" "time" - "github.com/btcsuite/btcdb" + "github.com/btcsuite/btcd/database" "github.com/btcsuite/btcnet" "github.com/btcsuite/btcutil" "github.com/btcsuite/btcwire" @@ -142,7 +142,7 @@ func removeChildNode(children []*blockNode, node *blockNode) []*blockNode { // follow all rules, orphan handling, checkpoint handling, and best chain // selection with reorganization. type BlockChain struct { - db btcdb.Db + db database.Db netParams *btcnet.Params checkpointsByHeight map[int64]*btcnet.Checkpoint notifications NotificationCallback @@ -1069,7 +1069,7 @@ func (b *BlockChain) IsCurrent(timeSource MedianTimeSource) bool { // Notification and NotificationType for details on the types and contents of // notifications. The provided callback can be nil if the caller is not // interested in receiving notifications. -func New(db btcdb.Db, params *btcnet.Params, c NotificationCallback) *BlockChain { +func New(db database.Db, params *btcnet.Params, c NotificationCallback) *BlockChain { // Generate a checkpoint by height map from the provided checkpoints. var checkpointsByHeight map[int64]*btcnet.Checkpoint if len(params.Checkpoints) > 0 { diff --git a/common_test.go b/common_test.go index 64a14064..7b6c692f 100644 --- a/common_test.go +++ b/common_test.go @@ -14,9 +14,9 @@ import ( "strings" "github.com/btcsuite/btcchain" - "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/btcnet" "github.com/btcsuite/btcutil" "github.com/btcsuite/btcwire" @@ -41,7 +41,7 @@ func fileExists(name string) bool { // isSupportedDbType returns whether or not the passed database type is // currently supported. func isSupportedDbType(dbType string) bool { - supportedDBs := btcdb.SupportedDBs() + supportedDBs := database.SupportedDBs() for _, sDbType := range supportedDBs { if dbType == sDbType { return true @@ -61,10 +61,10 @@ func chainSetup(dbName string) (*btcchain.BlockChain, func(), error) { // Handle memory database specially since it doesn't need the disk // specific handling. - var db btcdb.Db + var db database.Db var teardown func() if testDbType == "memdb" { - ndb, err := btcdb.CreateDB(testDbType) + ndb, err := database.CreateDB(testDbType) if err != nil { return nil, nil, fmt.Errorf("error creating db: %v", err) } @@ -88,7 +88,7 @@ func chainSetup(dbName string) (*btcchain.BlockChain, func(), error) { // Create a new database to store the accepted blocks into. dbPath := filepath.Join(testDbRoot, dbName) _ = os.RemoveAll(dbPath) - ndb, err := btcdb.CreateDB(testDbType, dbPath) + ndb, err := database.CreateDB(testDbType, dbPath) if err != nil { return nil, nil, fmt.Errorf("error creating db: %v", err) } diff --git a/example_test.go b/example_test.go index f30f9e56..4bbb1248 100644 --- a/example_test.go +++ b/example_test.go @@ -9,8 +9,8 @@ import ( "math/big" "github.com/btcsuite/btcchain" - "github.com/btcsuite/btcdb" - _ "github.com/btcsuite/btcdb/memdb" + "github.com/btcsuite/btcd/database" + _ "github.com/btcsuite/btcd/database/memdb" "github.com/btcsuite/btcnet" "github.com/btcsuite/btcutil" ) @@ -25,7 +25,7 @@ func ExampleBlockChain_ProcessBlock() { // this would be opening an existing database and would not use memdb // which is a memory-only database backend, but we create a new db // here so this is a complete working example. - db, err := btcdb.CreateDB("memdb") + db, err := database.CreateDB("memdb") if err != nil { fmt.Printf("Failed to create database: %v\n", err) return diff --git a/txlookup.go b/txlookup.go index 95484b6a..6925ef75 100644 --- a/txlookup.go +++ b/txlookup.go @@ -7,7 +7,7 @@ package btcchain import ( "fmt" - "github.com/btcsuite/btcdb" + "github.com/btcsuite/btcd/database" "github.com/btcsuite/btcutil" "github.com/btcsuite/btcwire" ) @@ -77,7 +77,7 @@ func disconnectTransactions(txStore TxStore, block *btcutil.Block) error { txD.Tx = nil txD.BlockHeight = 0 txD.Spent = nil - txD.Err = btcdb.ErrTxShaMissing + txD.Err = database.ErrTxShaMissing } // Unspend the origin transaction output. @@ -101,7 +101,7 @@ func disconnectTransactions(txStore TxStore, block *btcutil.Block) error { // transactions from the point of view of the end of the main chain. It takes // a flag which specifies whether or not fully spent transaction should be // included in the results. -func fetchTxStoreMain(db btcdb.Db, txSet map[btcwire.ShaHash]struct{}, includeSpent bool) TxStore { +func fetchTxStoreMain(db database.Db, txSet map[btcwire.ShaHash]struct{}, includeSpent bool) TxStore { // Just return an empty store now if there are no requested hashes. txStore := make(TxStore) if len(txSet) == 0 { @@ -114,7 +114,7 @@ func fetchTxStoreMain(db btcdb.Db, txSet map[btcwire.ShaHash]struct{}, includeSp txList := make([]*btcwire.ShaHash, 0, len(txSet)) for hash := range txSet { hashCopy := hash - txStore[hash] = &TxData{Hash: &hashCopy, Err: btcdb.ErrTxShaMissing} + txStore[hash] = &TxData{Hash: &hashCopy, Err: database.ErrTxShaMissing} txList = append(txList, &hashCopy) } @@ -253,7 +253,7 @@ func (b *BlockChain) fetchInputTransactions(node *blockNode, block *btcutil.Bloc // Add an entry to the transaction store for the needed // transaction with it set to missing by default. originHash := &txIn.PreviousOutPoint.Hash - txD := &TxData{Hash: originHash, Err: btcdb.ErrTxShaMissing} + txD := &TxData{Hash: originHash, Err: database.ErrTxShaMissing} txStore[*originHash] = txD // It is acceptable for a transaction input to reference diff --git a/validate.go b/validate.go index a64b950c..f878d953 100644 --- a/validate.go +++ b/validate.go @@ -11,7 +11,7 @@ import ( "math/big" "time" - "github.com/btcsuite/btcdb" + "github.com/btcsuite/btcd/database" "github.com/btcsuite/btcnet" "github.com/btcsuite/btcscript" "github.com/btcsuite/btcutil" @@ -627,7 +627,7 @@ func (b *BlockChain) checkBIP0030(node *blockNode, block *btcutil.Block) error { switch txD.Err { // A duplicate transaction was not found. This is the most // common case. - case btcdb.ErrTxShaMissing: + case database.ErrTxShaMissing: continue // A duplicate transaction was found. This is only allowed if