diff --git a/db.go b/db.go index b15c95b6..3f6d418c 100644 --- a/db.go +++ b/db.go @@ -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 @@ -145,7 +153,7 @@ type DriverDB struct { type TxListReply struct { Sha *btcwire.ShaHash Tx *btcwire.MsgTx - BlkSha *btcwire.ShaHash + BlkSha *btcwire.ShaHash Height int64 TxSpent []bool Err error diff --git a/ldb/dbcache.go b/ldb/dbcache.go index 92b5fbc3..e430819c 100644 --- a/ldb/dbcache.go +++ b/ldb/dbcache.go @@ -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 { diff --git a/sqlite3/sqlitedbcache.go b/sqlite3/sqlitedbcache.go index 3ec61a09..3caef680 100644 --- a/sqlite3/sqlitedbcache.go +++ b/sqlite3/sqlitedbcache.go @@ -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 {