aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/db.cpp22
-rw-r--r--src/db.h6
-rw-r--r--src/qt/guiconstants.h6
-rw-r--r--src/qt/transactiontablemodel.cpp29
-rw-r--r--src/rpcnet.cpp2
-rw-r--r--src/utilstrencodings.cpp4
-rw-r--r--src/walletdb.cpp4
-rw-r--r--src/walletdb.h19
8 files changed, 45 insertions, 47 deletions
diff --git a/src/db.cpp b/src/db.cpp
index edbff6fd49..24206d34e1 100644
--- a/src/db.cpp
+++ b/src/db.cpp
@@ -215,7 +215,7 @@ bool CDBEnv::Salvage(std::string strFile, bool fAggressive,
}
-void CDBEnv::CheckpointLSN(std::string strFile)
+void CDBEnv::CheckpointLSN(const std::string& strFile)
{
dbenv.txn_checkpoint(0, 0, 0);
if (fMockDb)
@@ -224,12 +224,12 @@ void CDBEnv::CheckpointLSN(std::string strFile)
}
-CDB::CDB(const char *pszFile, const char* pszMode) :
+CDB::CDB(const std::string& strFilename, const char* pszMode) :
pdb(NULL), activeTxn(NULL)
{
int ret;
fReadOnly = (!strchr(pszMode, '+') && !strchr(pszMode, 'w'));
- if (pszFile == NULL)
+ if (strFilename.empty())
return;
bool fCreate = strchr(pszMode, 'c') != NULL;
@@ -242,7 +242,7 @@ CDB::CDB(const char *pszFile, const char* pszMode) :
if (!bitdb.Open(GetDataDir()))
throw runtime_error("CDB : Failed to open database environment.");
- strFile = pszFile;
+ strFile = strFilename;
++bitdb.mapFileUseCount[strFile];
pdb = bitdb.mapDb[strFile];
if (pdb == NULL)
@@ -255,14 +255,14 @@ CDB::CDB(const char *pszFile, const char* pszMode) :
DbMpoolFile*mpf = pdb->get_mpf();
ret = mpf->set_flags(DB_MPOOL_NOFILE, 1);
if (ret != 0)
- throw runtime_error(strprintf("CDB : Failed to configure for no temp file backing for database %s", pszFile));
+ throw runtime_error(strprintf("CDB : Failed to configure for no temp file backing for database %s", strFile));
}
- ret = pdb->open(NULL, // Txn pointer
- fMockDb ? NULL : pszFile, // Filename
- fMockDb ? pszFile : "main", // Logical db name
- DB_BTREE, // Database type
- nFlags, // Flags
+ ret = pdb->open(NULL, // Txn pointer
+ fMockDb ? NULL : strFile.c_str(), // Filename
+ fMockDb ? strFile.c_str() : "main", // Logical db name
+ DB_BTREE, // Database type
+ nFlags, // Flags
0);
if (ret != 0)
@@ -271,7 +271,7 @@ CDB::CDB(const char *pszFile, const char* pszMode) :
pdb = NULL;
--bitdb.mapFileUseCount[strFile];
strFile = "";
- throw runtime_error(strprintf("CDB : Error %d, can't open database %s", ret, pszFile));
+ throw runtime_error(strprintf("CDB : Error %d, can't open database %s", ret, strFile));
}
if (fCreate && !Exists(string("version")))
diff --git a/src/db.h b/src/db.h
index 999750ff3f..eab27f43af 100644
--- a/src/db.h
+++ b/src/db.h
@@ -69,7 +69,7 @@ public:
bool Open(const boost::filesystem::path &path);
void Close();
void Flush(bool fShutdown);
- void CheckpointLSN(std::string strFile);
+ void CheckpointLSN(const std::string& strFile);
void CloseDb(const std::string& strFile);
bool RemoveDb(const std::string& strFile);
@@ -96,11 +96,13 @@ protected:
DbTxn *activeTxn;
bool fReadOnly;
- explicit CDB(const char* pszFile, const char* pszMode="r+");
+ explicit CDB(const std::string& strFilename, const char* pszMode="r+");
~CDB() { Close(); }
+
public:
void Flush();
void Close();
+
private:
CDB(const CDB&);
void operator=(const CDB&);
diff --git a/src/qt/guiconstants.h b/src/qt/guiconstants.h
index 5ae4bc833d..4c8a67b663 100644
--- a/src/qt/guiconstants.h
+++ b/src/qt/guiconstants.h
@@ -23,6 +23,12 @@ static const int STATUSBAR_ICONSIZE = 16;
#define COLOR_NEGATIVE QColor(255, 0, 0)
/* Transaction list -- bare address (without label) */
#define COLOR_BAREADDRESS QColor(140, 140, 140)
+/* Transaction list -- TX status decoration - open until date */
+#define COLOR_TX_STATUS_OPENUNTILDATE QColor(64, 64, 255)
+/* Transaction list -- TX status decoration - offline */
+#define COLOR_TX_STATUS_OFFLINE QColor(192, 192, 192)
+/* Transaction list -- TX status decoration - default color */
+#define COLOR_BLACK QColor(0, 0, 0)
/* Tooltips longer than this (in characters) are converted into rich text,
so that they can be word-wrapped.
diff --git a/src/qt/transactiontablemodel.cpp b/src/qt/transactiontablemodel.cpp
index 734c7afc4e..2b869b4ea5 100644
--- a/src/qt/transactiontablemodel.cpp
+++ b/src/qt/transactiontablemodel.cpp
@@ -209,10 +209,7 @@ public:
}
return rec;
}
- else
- {
- return 0;
- }
+ return 0;
}
QString describe(TransactionRecord *rec, int unit)
@@ -225,7 +222,7 @@ public:
return TransactionDesc::toHTML(wallet, mi->second, rec, unit);
}
}
- return QString("");
+ return QString();
}
};
@@ -330,10 +327,7 @@ QString TransactionTableModel::formatTxDate(const TransactionRecord *wtx) const
{
return GUIUtil::dateTimeStr(wtx->time);
}
- else
- {
- return QString();
- }
+ return QString();
}
/* Look up address in address book, if found return label (address)
@@ -345,11 +339,11 @@ QString TransactionTableModel::lookupAddress(const std::string &address, bool to
QString description;
if(!label.isEmpty())
{
- description += label + QString(" ");
+ description += label;
}
if(label.isEmpty() || tooltip)
{
- description += QString("(") + QString::fromStdString(address) + QString(")");
+ description += QString(" (") + QString::fromStdString(address) + QString(")");
}
return description;
}
@@ -389,7 +383,6 @@ QVariant TransactionTableModel::txAddressDecoration(const TransactionRecord *wtx
default:
return QIcon(":/icons/tx_inout");
}
- return QVariant();
}
QString TransactionTableModel::formatTxToAddress(const TransactionRecord *wtx, bool tooltip) const
@@ -456,9 +449,9 @@ QVariant TransactionTableModel::txStatusDecoration(const TransactionRecord *wtx)
{
case TransactionStatus::OpenUntilBlock:
case TransactionStatus::OpenUntilDate:
- return QColor(64,64,255);
+ return COLOR_TX_STATUS_OPENUNTILDATE;
case TransactionStatus::Offline:
- return QColor(192,192,192);
+ return COLOR_TX_STATUS_OFFLINE;
case TransactionStatus::Unconfirmed:
return QIcon(":/icons/transaction_0");
case TransactionStatus::Confirming:
@@ -482,8 +475,9 @@ QVariant TransactionTableModel::txStatusDecoration(const TransactionRecord *wtx)
case TransactionStatus::MaturesWarning:
case TransactionStatus::NotAccepted:
return QIcon(":/icons/transaction_0");
+ default:
+ return COLOR_BLACK;
}
- return QColor(0,0,0);
}
QVariant TransactionTableModel::txWatchonlyDecoration(const TransactionRecord *wtx) const
@@ -646,10 +640,7 @@ QModelIndex TransactionTableModel::index(int row, int column, const QModelIndex
{
return createIndex(row, column, priv->index(row));
}
- else
- {
- return QModelIndex();
- }
+ return QModelIndex();
}
void TransactionTableModel::updateDisplayUnit()
diff --git a/src/rpcnet.cpp b/src/rpcnet.cpp
index 52f98fbf00..95f42eb47f 100644
--- a/src/rpcnet.cpp
+++ b/src/rpcnet.cpp
@@ -96,7 +96,7 @@ Value getpeerinfo(const Array& params, bool fHelp)
" \"inbound\": true|false, (boolean) Inbound (true) or Outbound (false)\n"
" \"startingheight\": n, (numeric) The starting height (block) of the peer\n"
" \"banscore\": n, (numeric) The ban score\n"
- " \"syncnode\": true|false (booleamn) if sync node\n"
+ " \"syncnode\": true|false (boolean) if sync node\n"
" }\n"
" ,...\n"
"]\n"
diff --git a/src/utilstrencodings.cpp b/src/utilstrencodings.cpp
index 6837e4e267..2cec3023b5 100644
--- a/src/utilstrencodings.cpp
+++ b/src/utilstrencodings.cpp
@@ -224,7 +224,7 @@ vector<unsigned char> DecodeBase64(const char* p, bool* pfInvalid)
string DecodeBase64(const string& str)
{
vector<unsigned char> vchRet = DecodeBase64(str.c_str());
- return string((const char*)&vchRet[0], vchRet.size());
+ return (vchRet.size() == 0) ? string() : string((const char*)&vchRet[0], vchRet.size());
}
string EncodeBase32(const unsigned char* pch, size_t len)
@@ -411,7 +411,7 @@ vector<unsigned char> DecodeBase32(const char* p, bool* pfInvalid)
string DecodeBase32(const string& str)
{
vector<unsigned char> vchRet = DecodeBase32(str.c_str());
- return string((const char*)&vchRet[0], vchRet.size());
+ return (vchRet.size() == 0) ? string() : string((const char*)&vchRet[0], vchRet.size());
}
bool ParseInt32(const std::string& str, int32_t *out)
diff --git a/src/walletdb.cpp b/src/walletdb.cpp
index 03161250db..a84f44db01 100644
--- a/src/walletdb.cpp
+++ b/src/walletdb.cpp
@@ -242,9 +242,7 @@ void CWalletDB::ListAccountCreditDebit(const string& strAccount, list<CAccountin
pcursor->close();
}
-
-DBErrors
-CWalletDB::ReorderTransactions(CWallet* pwallet)
+DBErrors CWalletDB::ReorderTransactions(CWallet* pwallet)
{
LOCK(pwallet->cs_wallet);
// Old wallets didn't have any defined order for transactions
diff --git a/src/walletdb.h b/src/walletdb.h
index ce63bb0b97..2c5b608f3d 100644
--- a/src/walletdb.h
+++ b/src/walletdb.h
@@ -75,13 +75,10 @@ public:
class CWalletDB : public CDB
{
public:
- CWalletDB(std::string strFilename, const char* pszMode="r+") : CDB(strFilename.c_str(), pszMode)
+ CWalletDB(const std::string& strFilename, const char* pszMode = "r+") : CDB(strFilename, pszMode)
{
}
-private:
- CWalletDB(const CWalletDB&);
- void operator=(const CWalletDB&);
-public:
+
bool WriteName(const std::string& strAddress, const std::string& strName);
bool EraseName(const std::string& strAddress);
@@ -119,19 +116,23 @@ public:
bool WriteDestData(const std::string &address, const std::string &key, const std::string &value);
/// Erase destination data tuple from wallet database
bool EraseDestData(const std::string &address, const std::string &key);
-private:
- bool WriteAccountingEntry(const uint64_t nAccEntryNum, const CAccountingEntry& acentry);
-public:
+
bool WriteAccountingEntry(const CAccountingEntry& acentry);
int64_t GetAccountCreditDebit(const std::string& strAccount);
void ListAccountCreditDebit(const std::string& strAccount, std::list<CAccountingEntry>& acentries);
- DBErrors ReorderTransactions(CWallet*);
+ DBErrors ReorderTransactions(CWallet* pwallet);
DBErrors LoadWallet(CWallet* pwallet);
DBErrors FindWalletTx(CWallet* pwallet, std::vector<uint256>& vTxHash, std::vector<CWalletTx>& vWtx);
DBErrors ZapWalletTx(CWallet* pwallet, std::vector<CWalletTx>& vWtx);
static bool Recover(CDBEnv& dbenv, std::string filename, bool fOnlyKeys);
static bool Recover(CDBEnv& dbenv, std::string filename);
+
+private:
+ CWalletDB(const CWalletDB&);
+ void operator=(const CWalletDB&);
+
+ bool WriteAccountingEntry(const uint64_t nAccEntryNum, const CAccountingEntry& acentry);
};
bool BackupWallet(const CWallet& wallet, const std::string& strDest);