Update database import paths to new location.

This commit is contained in:
Dave Collins 2015-01-27 15:00:49 -06:00
parent 0565be965a
commit dd512e7315
5 changed files with 20 additions and 20 deletions

View file

@ -13,7 +13,7 @@ import (
"sync" "sync"
"time" "time"
"github.com/btcsuite/btcdb" "github.com/btcsuite/btcd/database"
"github.com/btcsuite/btcnet" "github.com/btcsuite/btcnet"
"github.com/btcsuite/btcutil" "github.com/btcsuite/btcutil"
"github.com/btcsuite/btcwire" "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 // follow all rules, orphan handling, checkpoint handling, and best chain
// selection with reorganization. // selection with reorganization.
type BlockChain struct { type BlockChain struct {
db btcdb.Db db database.Db
netParams *btcnet.Params netParams *btcnet.Params
checkpointsByHeight map[int64]*btcnet.Checkpoint checkpointsByHeight map[int64]*btcnet.Checkpoint
notifications NotificationCallback notifications NotificationCallback
@ -1069,7 +1069,7 @@ func (b *BlockChain) IsCurrent(timeSource MedianTimeSource) bool {
// Notification and NotificationType for details on the types and contents of // Notification and NotificationType for details on the types and contents of
// notifications. The provided callback can be nil if the caller is not // notifications. The provided callback can be nil if the caller is not
// interested in receiving notifications. // 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. // Generate a checkpoint by height map from the provided checkpoints.
var checkpointsByHeight map[int64]*btcnet.Checkpoint var checkpointsByHeight map[int64]*btcnet.Checkpoint
if len(params.Checkpoints) > 0 { if len(params.Checkpoints) > 0 {

View file

@ -14,9 +14,9 @@ import (
"strings" "strings"
"github.com/btcsuite/btcchain" "github.com/btcsuite/btcchain"
"github.com/btcsuite/btcdb" "github.com/btcsuite/btcd/database"
_ "github.com/btcsuite/btcdb/ldb" _ "github.com/btcsuite/btcd/database/ldb"
_ "github.com/btcsuite/btcdb/memdb" _ "github.com/btcsuite/btcd/database/memdb"
"github.com/btcsuite/btcnet" "github.com/btcsuite/btcnet"
"github.com/btcsuite/btcutil" "github.com/btcsuite/btcutil"
"github.com/btcsuite/btcwire" "github.com/btcsuite/btcwire"
@ -41,7 +41,7 @@ func fileExists(name string) bool {
// isSupportedDbType returns whether or not the passed database type is // isSupportedDbType returns whether or not the passed database type is
// currently supported. // currently supported.
func isSupportedDbType(dbType string) bool { func isSupportedDbType(dbType string) bool {
supportedDBs := btcdb.SupportedDBs() supportedDBs := database.SupportedDBs()
for _, sDbType := range supportedDBs { for _, sDbType := range supportedDBs {
if dbType == sDbType { if dbType == sDbType {
return true 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 // Handle memory database specially since it doesn't need the disk
// specific handling. // specific handling.
var db btcdb.Db var db database.Db
var teardown func() var teardown func()
if testDbType == "memdb" { if testDbType == "memdb" {
ndb, err := btcdb.CreateDB(testDbType) ndb, err := database.CreateDB(testDbType)
if err != nil { if err != nil {
return nil, nil, fmt.Errorf("error creating db: %v", err) 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. // Create a new database to store the accepted blocks into.
dbPath := filepath.Join(testDbRoot, dbName) dbPath := filepath.Join(testDbRoot, dbName)
_ = os.RemoveAll(dbPath) _ = os.RemoveAll(dbPath)
ndb, err := btcdb.CreateDB(testDbType, dbPath) ndb, err := database.CreateDB(testDbType, dbPath)
if err != nil { if err != nil {
return nil, nil, fmt.Errorf("error creating db: %v", err) return nil, nil, fmt.Errorf("error creating db: %v", err)
} }

View file

@ -9,8 +9,8 @@ import (
"math/big" "math/big"
"github.com/btcsuite/btcchain" "github.com/btcsuite/btcchain"
"github.com/btcsuite/btcdb" "github.com/btcsuite/btcd/database"
_ "github.com/btcsuite/btcdb/memdb" _ "github.com/btcsuite/btcd/database/memdb"
"github.com/btcsuite/btcnet" "github.com/btcsuite/btcnet"
"github.com/btcsuite/btcutil" "github.com/btcsuite/btcutil"
) )
@ -25,7 +25,7 @@ func ExampleBlockChain_ProcessBlock() {
// this would be opening an existing database and would not use memdb // 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 // which is a memory-only database backend, but we create a new db
// here so this is a complete working example. // here so this is a complete working example.
db, err := btcdb.CreateDB("memdb") db, err := database.CreateDB("memdb")
if err != nil { if err != nil {
fmt.Printf("Failed to create database: %v\n", err) fmt.Printf("Failed to create database: %v\n", err)
return return

View file

@ -7,7 +7,7 @@ package btcchain
import ( import (
"fmt" "fmt"
"github.com/btcsuite/btcdb" "github.com/btcsuite/btcd/database"
"github.com/btcsuite/btcutil" "github.com/btcsuite/btcutil"
"github.com/btcsuite/btcwire" "github.com/btcsuite/btcwire"
) )
@ -77,7 +77,7 @@ func disconnectTransactions(txStore TxStore, block *btcutil.Block) error {
txD.Tx = nil txD.Tx = nil
txD.BlockHeight = 0 txD.BlockHeight = 0
txD.Spent = nil txD.Spent = nil
txD.Err = btcdb.ErrTxShaMissing txD.Err = database.ErrTxShaMissing
} }
// Unspend the origin transaction output. // 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 // 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 // a flag which specifies whether or not fully spent transaction should be
// included in the results. // 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. // Just return an empty store now if there are no requested hashes.
txStore := make(TxStore) txStore := make(TxStore)
if len(txSet) == 0 { 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)) txList := make([]*btcwire.ShaHash, 0, len(txSet))
for hash := range txSet { for hash := range txSet {
hashCopy := hash hashCopy := hash
txStore[hash] = &TxData{Hash: &hashCopy, Err: btcdb.ErrTxShaMissing} txStore[hash] = &TxData{Hash: &hashCopy, Err: database.ErrTxShaMissing}
txList = append(txList, &hashCopy) 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 // Add an entry to the transaction store for the needed
// transaction with it set to missing by default. // transaction with it set to missing by default.
originHash := &txIn.PreviousOutPoint.Hash originHash := &txIn.PreviousOutPoint.Hash
txD := &TxData{Hash: originHash, Err: btcdb.ErrTxShaMissing} txD := &TxData{Hash: originHash, Err: database.ErrTxShaMissing}
txStore[*originHash] = txD txStore[*originHash] = txD
// It is acceptable for a transaction input to reference // It is acceptable for a transaction input to reference

View file

@ -11,7 +11,7 @@ import (
"math/big" "math/big"
"time" "time"
"github.com/btcsuite/btcdb" "github.com/btcsuite/btcd/database"
"github.com/btcsuite/btcnet" "github.com/btcsuite/btcnet"
"github.com/btcsuite/btcscript" "github.com/btcsuite/btcscript"
"github.com/btcsuite/btcutil" "github.com/btcsuite/btcutil"
@ -627,7 +627,7 @@ func (b *BlockChain) checkBIP0030(node *blockNode, block *btcutil.Block) error {
switch txD.Err { switch txD.Err {
// A duplicate transaction was not found. This is the most // A duplicate transaction was not found. This is the most
// common case. // common case.
case btcdb.ErrTxShaMissing: case database.ErrTxShaMissing:
continue continue
// A duplicate transaction was found. This is only allowed if // A duplicate transaction was found. This is only allowed if