Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/wallet.h
Show First 20 Lines • Show All 1,389 Lines • ▼ Show 20 Lines | |||||
* resend their transactions. Actual rebroadcast schedule is managed by the | * resend their transactions. Actual rebroadcast schedule is managed by the | ||||
* wallets themselves. | * wallets themselves. | ||||
*/ | */ | ||||
void MaybeResendWalletTxs(); | void MaybeResendWalletTxs(); | ||||
/** RAII object to check and reserve a wallet rescan */ | /** RAII object to check and reserve a wallet rescan */ | ||||
class WalletRescanReserver { | class WalletRescanReserver { | ||||
private: | private: | ||||
CWallet *m_wallet; | CWallet &m_wallet; | ||||
bool m_could_reserve; | bool m_could_reserve; | ||||
public: | public: | ||||
explicit WalletRescanReserver(CWallet *w) | explicit WalletRescanReserver(CWallet &w) | ||||
: m_wallet(w), m_could_reserve(false) {} | : m_wallet(w), m_could_reserve(false) {} | ||||
bool reserve() { | bool reserve() { | ||||
assert(!m_could_reserve); | assert(!m_could_reserve); | ||||
std::lock_guard<std::mutex> lock(m_wallet->mutexScanning); | std::lock_guard<std::mutex> lock(m_wallet.mutexScanning); | ||||
if (m_wallet->fScanningWallet) { | if (m_wallet.fScanningWallet) { | ||||
return false; | return false; | ||||
} | } | ||||
m_wallet->m_scanning_start = GetTimeMillis(); | m_wallet.m_scanning_start = GetTimeMillis(); | ||||
m_wallet->m_scanning_progress = 0; | m_wallet.m_scanning_progress = 0; | ||||
m_wallet->fScanningWallet = true; | m_wallet.fScanningWallet = true; | ||||
m_could_reserve = true; | m_could_reserve = true; | ||||
return true; | return true; | ||||
} | } | ||||
bool isReserved() const { | bool isReserved() const { | ||||
return (m_could_reserve && m_wallet->fScanningWallet); | return (m_could_reserve && m_wallet.fScanningWallet); | ||||
} | } | ||||
~WalletRescanReserver() { | ~WalletRescanReserver() { | ||||
std::lock_guard<std::mutex> lock(m_wallet->mutexScanning); | std::lock_guard<std::mutex> lock(m_wallet.mutexScanning); | ||||
if (m_could_reserve) { | if (m_could_reserve) { | ||||
m_wallet->fScanningWallet = false; | m_wallet.fScanningWallet = false; | ||||
} | } | ||||
} | } | ||||
}; | }; | ||||
// Calculate the size of the transaction assuming all signatures are max size | // Calculate the size of the transaction assuming all signatures are max size | ||||
// Use DummySignatureCreator, which inserts 71 byte signatures everywhere. | // Use DummySignatureCreator, which inserts 71 byte signatures everywhere. | ||||
// NOTE: this requires that all inputs must be in mapWallet (eg the tx should | // NOTE: this requires that all inputs must be in mapWallet (eg the tx should | ||||
// be IsAllFromMe). | // be IsAllFromMe). | ||||
Show All 10 Lines |