Add minor optimization to transaction store fetch.
This commit adds a quick check to the transaction store fetch code which simply returns an empty store if no hashes were requested rather than bothering the db with an empty list.
This commit is contained in:
parent
e888372019
commit
39e7e5c4a1
1 changed files with 6 additions and 1 deletions
|
@ -102,11 +102,16 @@ func disconnectTransactions(txStore TxStore, block *btcutil.Block) error {
|
|||
// fetchTxStoreMain fetches transaction data about the provided set of
|
||||
// transactions from the point of view of the end of the main chain.
|
||||
func fetchTxStoreMain(db btcdb.Db, txSet map[btcwire.ShaHash]bool) TxStore {
|
||||
// Just return an empty store now if there are no requested hashes.
|
||||
txStore := make(TxStore)
|
||||
if len(txSet) == 0 {
|
||||
return txStore
|
||||
}
|
||||
|
||||
// The transaction store map needs to have an entry for every requested
|
||||
// transaction. By default, all the transactions are marked as missing.
|
||||
// Each entry will be filled in with the appropriate data below.
|
||||
txList := make([]*btcwire.ShaHash, 0, len(txSet))
|
||||
txStore := make(TxStore)
|
||||
for hash := range txSet {
|
||||
hashCopy := hash
|
||||
txStore[hash] = &TxData{Hash: &hashCopy, Err: btcdb.TxShaMissing}
|
||||
|
|
Loading…
Reference in a new issue