Skip to content

Commit

Permalink
Address additional review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Roasbeef committed Jan 21, 2015
1 parent 080fdb5 commit ee94a3e
Show file tree
Hide file tree
Showing 5 changed files with 149 additions and 139 deletions.
23 changes: 13 additions & 10 deletions db.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (

// Errors that the various database functions may return.
var (
ErrAddrIndexDoesNotExist = errors.New("Address index hasn't been built up yet.")
ErrAddrIndexDoesNotExist = errors.New("address index hasn't been built up yet")
ErrUnsupportedAddressType = errors.New("address type is not supported " +
"by the address-index")
ErrPrevShaMissing = errors.New("previous sha missing from database")
Expand Down Expand Up @@ -125,14 +125,14 @@ type Db interface {
// Addresses are indexed by the raw bytes of their base58 decoded
// hash160.
UpdateAddrIndexForBlock(blkSha *btcwire.ShaHash, height int64,
addrIndex *BlockAddrIndex) error

// FetchBlockBySha looks up and returns all transactions which either
// spend from a previously created output of the passed address, or
// create a new output locked to the passed address. The, `limit` parameter
// should be the max number of transactions to be returned. Additionally, if the
// caller wishes to seek forward in the results some amount, the 'seek'
// represents how many results to skip.
addrIndex BlockAddrIndex) error

// FetchTxsForAddr looks up and returns all transactions which either
// spend a previously created output of the passed address, or create
// a new output locked to the passed address. The, `limit` parameter
// should be the max number of transactions to be returned.
// Additionally, if the caller wishes to skip forward in the results
// some amount, the 'seek' represents how many results to skip.
FetchTxsForAddr(addr btcutil.Address, skip int, limit int) ([]*TxListReply, error)

// DeleteAddrIndex deletes the entire addrindex stored within the DB.
Expand Down Expand Up @@ -166,10 +166,13 @@ type TxListReply struct {
Err error
}

// AddrIndexKeySize is the number of bytes used by keys into the BlockAddrIndex.
const AddrIndexKeySize = ripemd160.Size

// BlockAddrIndex represents the indexing structure for addresses.
// It maps a hash160 to a list of transaction locations within a block that
// either pays to or spends from the passed UTXO for the hash160.
type BlockAddrIndex map[[ripemd160.Size]byte][]*btcwire.TxLoc
type BlockAddrIndex map[[AddrIndexKeySize]byte][]*btcwire.TxLoc

// driverList holds all of the registered database backends.
var driverList []DriverDB
Expand Down
4 changes: 2 additions & 2 deletions ldb/internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

"testing"

"github.com/conformal/btcutil"
"github.com/btcsuite/btcutil"
"golang.org/x/crypto/ripemd160"
)

Expand Down Expand Up @@ -59,6 +59,6 @@ func TestBytesPrefix(t *testing.T) {

if !bytes.Equal(prefixRange.Limit, []byte("b")) {
t.Errorf("Wrong prefix end, got %d, expected %d", prefixRange.Limit,
[]byte("a"))
[]byte("b"))
}
}
Loading

0 comments on commit ee94a3e

Please sign in to comment.