Skip to content

Commit 67d37eb

Browse files
committed
Use ENABLE_WALLET to wrap wallet transaction cache
1 parent 7a26c6b commit 67d37eb

File tree

2 files changed

+25
-11
lines changed

2 files changed

+25
-11
lines changed

src/omnicore/walletcache.cpp

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
// Provides a cache of wallet balances and functionality for determining whether Omni state changes affected anything in the wallet
1+
/**
2+
* @file walletcache.cpp
3+
*
4+
* Provides a cache of wallet balances and functionality for determining whether
5+
* Omni state changes affected anything in the wallet.
6+
*/
7+
28
#include "omnicore/walletcache.h"
39

410
#include "omnicore/log.h"
@@ -9,7 +15,9 @@
915
#include "init.h"
1016
#include "sync.h"
1117
#include "uint256.h"
18+
#ifdef ENABLE_WALLET
1219
#include "wallet.h"
20+
#endif
1321

1422
#include <stdint.h>
1523
#include <algorithm>
@@ -20,16 +28,16 @@
2028
#include <utility>
2129
#include <vector>
2230

23-
using namespace mastercore;
24-
31+
namespace mastercore
32+
{
2533
//! Global vector of Omni transactions in the wallet
2634
std::vector<uint256> walletTXIDCache;
2735

2836
//! Map of wallet balances
2937
static std::map<std::string, CMPTally> walletBalancesCache;
3038

3139
/**
32-
* Adds a txid to the wallet txid cache, performing duplicate detection
40+
* Adds a txid to the wallet txid cache, performing duplicate detection.
3341
*/
3442
void WalletTXIDCacheAdd(const uint256& hash)
3543
{
@@ -42,21 +50,21 @@ void WalletTXIDCacheAdd(const uint256& hash)
4250
}
4351

4452
/**
45-
* Performs initial population of the wallet txid cache
53+
* Performs initial population of the wallet txid cache.
4654
*/
4755
void WalletTXIDCacheInit()
4856
{
4957
if (msc_debug_walletcache) PrintToLog("WALLETTXIDCACHE: WalletTXIDCacheInit requested\n");
50-
58+
#ifdef ENABLE_WALLET
5159
LOCK2(cs_tally, pwalletMain->cs_wallet);
5260

5361
std::list<CAccountingEntry> acentries;
5462
CWallet::TxItems txOrdered = pwalletMain->OrderedTxItems(acentries, "*");
5563

5664
// Iterate through the wallet, checking if each transaction is Omni (via levelDB)
5765
for (CWallet::TxItems::reverse_iterator it = txOrdered.rbegin(); it != txOrdered.rend(); ++it) {
58-
CWalletTx *const pwtx = (*it).second.first;
59-
if (pwtx != 0) {
66+
const CWalletTx* pwtx = it->second.first;
67+
if (pwtx != NULL) {
6068
// get the hash of the transaction and check leveldb to see if this is an Omni tx, if so add to cache
6169
const uint256& hash = pwtx->GetHash();
6270
if (p_txlistdb->exists(hash)) {
@@ -65,11 +73,13 @@ void WalletTXIDCacheInit()
6573
}
6674
}
6775
}
76+
#endif
6877
}
6978

7079
/**
71-
* Updates the cache with the latest state, returning true if changes were made to wallet addresses (including watch only)
72-
* Also prepares a list of addresses that were changed (for future usage)
80+
* Updates the cache with the latest state, returning true if changes were made to wallet addresses (including watch only).
81+
*
82+
* Also prepares a list of addresses that were changed (for future usage).
7383
*/
7484
int WalletCacheUpdate()
7585
{
@@ -125,3 +135,5 @@ int WalletCacheUpdate()
125135
return numChanges;
126136
}
127137

138+
139+
} // namespace mastercore

src/omnicore/walletcache.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ class uint256;
55

66
#include <vector>
77

8+
namespace mastercore
9+
{
810
//! Global vector of Omni transactions in the wallet
911
extern std::vector<uint256> walletTXIDCache;
1012

@@ -16,6 +18,6 @@ void WalletTXIDCacheInit();
1618

1719
/** Updates the cache and returns whether any wallet addresses were changed */
1820
int WalletCacheUpdate();
19-
21+
}
2022

2123
#endif // OMNICORE_WALLETCACHE_H

0 commit comments

Comments
 (0)