Add Api to fetch potentially fully spent tx (most recent only)

Using FetchUnSpentTxByShaList only API required unexpected contortions
in btcchain.
This commit is contained in:
Dale Rahn 2013-10-13 11:08:21 -04:00
parent 2ec9511891
commit 75896b63ec
3 changed files with 24 additions and 2 deletions

10
db.go
View file

@ -79,7 +79,15 @@ type Db interface {
// FetchTxByShaList returns a TxListReply given an array of transaction
// hashes. The implementation may cache the underlying data if desired.
FetchUnSpentTxByShaList(txShaList []*btcwire.ShaHash) ([]*TxListReply)
// This differs from FetchUnSpentTxByShaList in that it will return
// the most recent known Tx, if it is fully spent or not.
FetchTxByShaList(txShaList []*btcwire.ShaHash) []*TxListReply
// FetchUnSpentTxByShaList returns a TxListReply given an array of
// transaction hashes. The implementation may cache the underlying
// data if desired. Fully spent transactions will not normally not
// be returned in this operation.
FetchUnSpentTxByShaList(txShaList []*btcwire.ShaHash) []*TxListReply
// InsertBlock inserts raw block and transaction data from a block
// into the database. The first block inserted into the database

View file

@ -36,6 +36,13 @@ func (db *LevelDb) fetchBlockBySha(sha *btcwire.ShaHash) (blk *btcutil.Block, er
return
}
// FetchTxByShaList returns the most recent tx of the name fully spent or not
func (db *LevelDb) FetchTxByShaList(txShaList []*btcwire.ShaHash) []*btcdb.TxListReply {
// until the fully spent separation of tx is complete this is identical
// to FetchUnSpentTxByShaList
return db.FetchUnSpentTxByShaList(txShaList)
}
// FetchUnSpentTxByShaList given a array of ShaHash, look up the transactions
// and return them in a TxListReply array.
func (db *LevelDb) FetchUnSpentTxByShaList(txShaList []*btcwire.ShaHash) []*btcdb.TxListReply {

View file

@ -131,6 +131,13 @@ func (db *SqliteDb) insertBlockCache(sha *btcwire.ShaHash, blk *btcutil.Block) {
bc.blockMap[blkObj.sha] = &blkObj
}
// FetchTxByShaList returns the most recent tx of the name fully spent or not
func (db *SqliteDb) FetchTxByShaList(txShaList []*btcwire.ShaHash) []*btcdb.TxListReply {
// until the fully spent separation of tx is complete this is identical
// to FetchUnSpentTxByShaList
return db.FetchUnSpentTxByShaList(txShaList)
}
// FetchUnSpentTxByShaList given a array of ShaHash, look up the transactions
// and return them in a TxListReply array.
func (db *SqliteDb) FetchUnSpentTxByShaList(txShaList []*btcwire.ShaHash) []*btcdb.TxListReply {