diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/qt/bitcoingui.cpp | 3 | ||||
| -rw-r--r-- | src/qt/forms/signverifymessagedialog.ui | 2 | ||||
| -rw-r--r-- | src/qt/walletmodel.cpp | 25 | ||||
| -rw-r--r-- | src/util.h | 48 |
4 files changed, 56 insertions, 22 deletions
diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index 878c2887a..7b0e6f3bc 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -344,6 +344,7 @@ void BitcoinGUI::setClientModel(ClientModel *clientModel) this->clientModel = clientModel; if(clientModel) { + // Replace some strings and icons, when using the testnet if(clientModel->isTestNet()) { setWindowTitle(windowTitle() + QString(" ") + tr("[testnet]")); @@ -359,6 +360,8 @@ void BitcoinGUI::setClientModel(ClientModel *clientModel) trayIcon->setIcon(QIcon(":/icons/toolbar_testnet")); toggleHideAction->setIcon(QIcon(":/icons/toolbar_testnet")); } + + aboutAction->setIcon(QIcon(":/icons/toolbar_testnet")); } // Keep up to date with client diff --git a/src/qt/forms/signverifymessagedialog.ui b/src/qt/forms/signverifymessagedialog.ui index e22aea867..8128bdf45 100644 --- a/src/qt/forms/signverifymessagedialog.ui +++ b/src/qt/forms/signverifymessagedialog.ui @@ -11,7 +11,7 @@ </rect> </property> <property name="windowTitle"> - <string>Messaging - Sign / Verify a Message</string> + <string>Signatures - Sign / Verify a Message</string> </property> <property name="modal"> <bool>true</bool> diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp index 0111e0cd9..3568616cd 100644 --- a/src/qt/walletmodel.cpp +++ b/src/qt/walletmodel.cpp @@ -23,13 +23,10 @@ WalletModel::WalletModel(CWallet *wallet, OptionsModel *optionsModel, QObject *p addressTableModel = new AddressTableModel(wallet, this); transactionTableModel = new TransactionTableModel(wallet, this); - // This single-shot timer will be fired from the 'checkBalancedChanged' - // method repeatedly while either of the unconfirmed or immature balances - // are non-zero + // This timer will be fired repeatedly to update the balance pollTimer = new QTimer(this); - pollTimer->setInterval(MODEL_UPDATE_DELAY); - pollTimer->setSingleShot(true); connect(pollTimer, SIGNAL(timeout()), this, SLOT(pollBalanceChanged())); + pollTimer->start(MODEL_UPDATE_DELAY); subscribeToCoreSignals(); } @@ -74,13 +71,12 @@ void WalletModel::updateStatus() void WalletModel::pollBalanceChanged() { - if(nBestHeight != cachedNumBlocks) { + if(nBestHeight != cachedNumBlocks) + { + // Balance and number of transactions might have changed cachedNumBlocks = nBestHeight; checkBalanceChanged(); } - - if(cachedUnconfirmedBalance || cachedImmatureBalance) - pollTimer->start(); } void WalletModel::checkBalanceChanged() @@ -89,7 +85,8 @@ void WalletModel::checkBalanceChanged() qint64 newUnconfirmedBalance = getUnconfirmedBalance(); qint64 newImmatureBalance = getImmatureBalance(); - if(cachedBalance != newBalance || cachedUnconfirmedBalance != newUnconfirmedBalance || cachedImmatureBalance != newImmatureBalance) { + if(cachedBalance != newBalance || cachedUnconfirmedBalance != newUnconfirmedBalance || cachedImmatureBalance != newImmatureBalance) + { cachedBalance = newBalance; cachedUnconfirmedBalance = newUnconfirmedBalance; cachedImmatureBalance = newImmatureBalance; @@ -105,13 +102,11 @@ void WalletModel::updateTransaction(const QString &hash, int status) // Balance and number of transactions might have changed checkBalanceChanged(); - if(cachedUnconfirmedBalance || cachedImmatureBalance) - pollTimer->start(); - int newNumTransactions = getNumTransactions(); - if(cachedNumTransactions != newNumTransactions) { - emit numTransactionsChanged(newNumTransactions); + if(cachedNumTransactions != newNumTransactions) + { cachedNumTransactions = newNumTransactions; + emit numTransactionsChanged(newNumTransactions); } } diff --git a/src/util.h b/src/util.h index 7b2c67891..7fe204c0d 100644 --- a/src/util.h +++ b/src/util.h @@ -391,6 +391,46 @@ inline uint256 Hash(const T1 pbegin, const T1 pend) return hash2; } +class CHashWriter +{ +private: + SHA256_CTX ctx; + +public: + int nType; + int nVersion; + + void Init() { + SHA256_Init(&ctx); + } + + CHashWriter(int nTypeIn, int nVersionIn) : nType(nTypeIn), nVersion(nVersionIn) { + Init(); + } + + CHashWriter& write(const char *pch, size_t size) { + SHA256_Update(&ctx, pch, size); + return (*this); + } + + // invalidates the object + uint256 GetHash() { + uint256 hash1; + SHA256_Final((unsigned char*)&hash1, &ctx); + uint256 hash2; + SHA256((unsigned char*)&hash1, sizeof(hash1), (unsigned char*)&hash2); + return hash2; + } + + template<typename T> + CHashWriter& operator<<(const T& obj) { + // Serialize to this stream + ::Serialize(*this, obj, nType, nVersion); + return (*this); + } +}; + + template<typename T1, typename T2> inline uint256 Hash(const T1 p1begin, const T1 p1end, const T2 p2begin, const T2 p2end) @@ -428,13 +468,9 @@ inline uint256 Hash(const T1 p1begin, const T1 p1end, template<typename T> uint256 SerializeHash(const T& obj, int nType=SER_GETHASH, int nVersion=PROTOCOL_VERSION) { - // Most of the time is spent allocating and deallocating CDataStream's - // buffer. If this ever needs to be optimized further, make a CStaticStream - // class with its buffer on the stack. - CDataStream ss(nType, nVersion); - ss.reserve(10000); + CHashWriter ss(nType, nVersion); ss << obj; - return Hash(ss.begin(), ss.end()); + return ss.GetHash(); } inline uint160 Hash160(const std::vector<unsigned char>& vch) |