Skip to content

Commit e4c0237

Browse files
luke-jrpsolstice
authored andcommitted
wallet: Update formatting
1 parent 19fa389 commit e4c0237

File tree

2 files changed

+21
-27
lines changed

2 files changed

+21
-27
lines changed

src/wallet/wallet.cpp

+10-8
Original file line numberDiff line numberDiff line change
@@ -643,24 +643,25 @@ bool CWallet::Verify()
643643
}
644644

645645
std::string strError;
646-
if (!CWalletDB::VerifyEnvironment(walletFile, GetDataDir().string(), strError))
646+
if (!CWalletDB::VerifyEnvironment(walletFile, GetDataDir().string(), strError)) {
647647
return InitError(strError);
648+
}
648649

649-
if (GetBoolArg("-salvagewallet", false))
650-
{
650+
if (GetBoolArg("-salvagewallet", false)) {
651651
// Recover readable keypairs:
652652
CWallet dummyWallet;
653653
std::string backup_filename;
654-
if (!CWalletDB::Recover(walletFile, (void *)&dummyWallet, CWalletDB::RecoverKeysOnlyFilter, backup_filename))
654+
if (!CWalletDB::Recover(walletFile, (void *)&dummyWallet, CWalletDB::RecoverKeysOnlyFilter, backup_filename)) {
655655
return false;
656+
}
656657
}
657658

658659
std::string strWarning;
659660
bool dbV = CWalletDB::VerifyDatabaseFile(walletFile, GetDataDir().string(), strWarning, strError);
660-
if (!strWarning.empty())
661+
if (!strWarning.empty()) {
661662
InitWarning(strWarning);
662-
if (!dbV)
663-
{
663+
}
664+
if (!dbV) {
664665
InitError(strError);
665666
return false;
666667
}
@@ -5990,8 +5991,9 @@ bool CWallet::AddAccountingEntry(const CAccountingEntry& acentry)
59905991

59915992
bool CWallet::AddAccountingEntry(const CAccountingEntry& acentry, CWalletDB *pwalletdb)
59925993
{
5993-
if (!pwalletdb->WriteAccountingEntry(++nAccountingEntryNumber, acentry))
5994+
if (!pwalletdb->WriteAccountingEntry(++nAccountingEntryNumber, acentry)) {
59945995
return false;
5996+
}
59955997

59965998
laccentries.push_back(acentry);
59975999
CAccountingEntry & entry = laccentries.back();

src/wallet/walletdb.cpp

+11-19
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,9 @@ bool CWalletDB::EraseTx(uint256 hash)
8080

8181
bool CWalletDB::WriteKey(const CPubKey& vchPubKey, const CPrivKey& vchPrivKey, const CKeyMetadata& keyMeta)
8282
{
83-
nWalletDBUpdateCounter++;
84-
85-
if (!Write(std::make_pair(std::string("keymeta"), vchPubKey),
86-
keyMeta, false))
83+
if (!WriteIC(std::make_pair(std::string("keymeta"), vchPubKey), keyMeta, false)) {
8784
return false;
85+
}
8886

8987
// hash pubkey/privkey to accelerate wallet load
9088
std::vector<unsigned char> vchKey;
@@ -102,12 +100,13 @@ bool CWalletDB::WriteCryptedKey(const CPubKey& vchPubKey,
102100
const bool fEraseUnencryptedKey = true;
103101
nWalletDBUpdateCounter++;
104102

105-
if (!Write(std::make_pair(std::string("keymeta"), vchPubKey),
106-
keyMeta))
103+
if (!WriteIC(std::make_pair(std::string("keymeta"), vchPubKey), keyMeta)) {
107104
return false;
105+
}
108106

109-
if (!Write(std::make_pair(std::string("ckey"), vchPubKey), vchCryptedSecret, false))
107+
if (!WriteIC(std::make_pair(std::string("ckey"), vchPubKey), vchCryptedSecret, false)) {
110108
return false;
109+
}
111110
if (fEraseUnencryptedKey)
112111
{
113112
Erase(std::make_pair(std::string("key"), vchPubKey));
@@ -130,29 +129,22 @@ bool CWalletDB::WriteCScript(const uint160& hash, const CScript& redeemScript)
130129

131130
bool CWalletDB::WriteWatchOnly(const CScript &dest, const CKeyMetadata& keyMeta)
132131
{
132+
<<<<<<< HEAD
133133
nWalletDBUpdateCounter++;
134134
if (!Write(std::make_pair(std::string("watchmeta"), *(const CScriptBase*)(&dest)), keyMeta))
135135
return false;
136-
return Write(std::make_pair(std::string("watchs"), *(const CScriptBase*)(&dest)), '1');
136+
>>>>>>> c237bd750e... wallet: Update formatting
137137
}
138138

139139
bool CWalletDB::EraseWatchOnly(const CScript &dest)
140-
{
141-
nWalletDBUpdateCounter++;
142-
if (!Erase(std::make_pair(std::string("watchmeta"), *(const CScriptBase*)(&dest))))
140+
if (!EraseIC(std::make_pair(std::string("watchmeta"), *(const CScriptBase*)(&dest)))) {
143141
return false;
144-
return Erase(std::make_pair(std::string("watchs"), *(const CScriptBase*)(&dest)));
145-
}
146-
147-
bool CWalletDB::WriteBestBlock(const CBlockLocator& locator)
148-
{
149-
nWalletDBUpdateCounter++;
150-
Write(std::string("bestblock"), CBlockLocator()); // Write empty block locator so versions that require a merkle branch automatically rescan
142+
}
143+
return EraseIC(std::make_pair(std::string("watchs"), *(const CScriptBase*)(&dest)));
151144
return Write(std::string("bestblock_nomerkle"), locator);
152145
}
153146

154147
bool CWalletDB::ReadBestBlock(CBlockLocator& locator)
155-
{
156148
if (Read(std::string("bestblock"), locator) && !locator.vHave.empty()) return true;
157149
return Read(std::string("bestblock_nomerkle"), locator);
158150
}

0 commit comments

Comments
 (0)