Browse Source

Merge #10484: 0.14 Backports

1847642 [Wallet] unset change position when there is no change on exact match (Gregory Sanders)
ae479bc build: fix bitcoin-config.h regeneration after touching build files (Cory Fields)
3d395d6 build: remove wonky auto top-level convenience targets (Cory Fields)
4bc99c3 Add missing <atomic> header in clientmodel.h (Jonas Schnelli)
222f377 Set both time/height header caches at the same time (Jonas Schnelli)
7da1337 Declare headers height/time cache mutable, re-set the methods const (Jonas Schnelli)
9ac40e8 Update the remaining blocks left in modaloverlay at init. (Jonas Schnelli)
1e936d7 Reduce cs_main locks during modal overlay by adding an atomic cache (Jonas Schnelli)
0aee4a1 Check interruptNet during dnsseed lookups (Matt Corallo)
0.14
Wladimir J. van der Laan 7 years ago
parent
commit
ff3f9a807d
No known key found for this signature in database
GPG Key ID: 1E4AED62986CD25D
  1. 3
      Makefile.am
  2. 5
      qa/rpc-tests/fundrawtransaction.py
  3. 8
      src/Makefile.am
  4. 6
      src/net.cpp
  5. 3
      src/qt/bitcoingui.cpp
  6. 33
      src/qt/clientmodel.cpp
  7. 6
      src/qt/clientmodel.h
  8. 5
      src/wallet/wallet.cpp

3
Makefile.am

@ -76,9 +76,6 @@ $(BITCOIN_WIN_INSTALLER): all-recursive
echo error: could not build $@ echo error: could not build $@
@echo built $@ @echo built $@
$(if $(findstring src/,$(MAKECMDGOALS)),$(MAKECMDGOALS), none): FORCE
$(MAKE) -C src $(patsubst src/%,%,$@)
$(OSX_APP)/Contents/PkgInfo: $(OSX_APP)/Contents/PkgInfo:
$(MKDIR_P) $(@D) $(MKDIR_P) $(@D)
@echo "APPL????" > $@ @echo "APPL????" > $@

5
qa/rpc-tests/fundrawtransaction.py

@ -54,6 +54,11 @@ class RawTransactionsTest(BitcoinTestFramework):
self.nodes[0].generate(121) self.nodes[0].generate(121)
self.sync_all() self.sync_all()
# ensure that setting changePosition in fundraw with an exact match is handled properly
rawmatch = self.nodes[2].createrawtransaction([], {self.nodes[2].getnewaddress():50})
rawmatch = self.nodes[2].fundrawtransaction(rawmatch, {"changePosition":1, "subtractFeeFromOutputs":[0]})
assert_equal(rawmatch["changepos"], -1)
watchonly_address = self.nodes[0].getnewaddress() watchonly_address = self.nodes[0].getnewaddress()
watchonly_pubkey = self.nodes[0].validateaddress(watchonly_address)["pubkey"] watchonly_pubkey = self.nodes[0].validateaddress(watchonly_address)["pubkey"]
watchonly_amount = Decimal(200) watchonly_amount = Decimal(200)

8
src/Makefile.am

@ -457,6 +457,14 @@ DISTCLEANFILES = obj/build.h
EXTRA_DIST = $(CTAES_DIST) EXTRA_DIST = $(CTAES_DIST)
config/bitcoin-config.h: config/stamp-h1
@$(MAKE) -C $(top_builddir) $(subdir)/$(@)
config/stamp-h1: $(top_srcdir)/$(subdir)/config/bitcoin-config.h.in $(top_builddir)/config.status
$(AM_V_at)$(MAKE) -C $(top_builddir) $(subdir)/$(@)
$(top_srcdir)/$(subdir)/config/bitcoin-config.h.in: $(am__configure_deps)
$(AM_V_at)$(MAKE) -C $(top_srcdir) $(subdir)/config/bitcoin-config.h.in
clean-local: clean-local:
-$(MAKE) -C secp256k1 clean -$(MAKE) -C secp256k1 clean
-$(MAKE) -C univalue clean -$(MAKE) -C univalue clean

6
src/net.cpp

@ -1579,6 +1579,9 @@ void CConnman::ThreadDNSAddressSeed()
LogPrintf("Loading addresses from DNS seeds (could take a while)\n"); LogPrintf("Loading addresses from DNS seeds (could take a while)\n");
BOOST_FOREACH(const CDNSSeedData &seed, vSeeds) { BOOST_FOREACH(const CDNSSeedData &seed, vSeeds) {
if (interruptNet) {
return;
}
if (HaveNameProxy()) { if (HaveNameProxy()) {
AddOneShot(seed.host); AddOneShot(seed.host);
} else { } else {
@ -1596,6 +1599,9 @@ void CConnman::ThreadDNSAddressSeed()
found++; found++;
} }
} }
if (interruptNet) {
return;
}
// TODO: The seed name resolve may fail, yielding an IP of [::], which results in // TODO: The seed name resolve may fail, yielding an IP of [::], which results in
// addrman assigning the same source to results from different seeds. // addrman assigning the same source to results from different seeds.
// This should switch to a hard-coded stable dummy IP for each seed name, so that the // This should switch to a hard-coded stable dummy IP for each seed name, so that the

3
src/qt/bitcoingui.cpp

@ -478,6 +478,7 @@ void BitcoinGUI::setClientModel(ClientModel *_clientModel)
connect(_clientModel, SIGNAL(numConnectionsChanged(int)), this, SLOT(setNumConnections(int))); connect(_clientModel, SIGNAL(numConnectionsChanged(int)), this, SLOT(setNumConnections(int)));
connect(_clientModel, SIGNAL(networkActiveChanged(bool)), this, SLOT(setNetworkActive(bool))); connect(_clientModel, SIGNAL(networkActiveChanged(bool)), this, SLOT(setNetworkActive(bool)));
modalOverlay->setKnownBestHeight(_clientModel->getHeaderTipHeight(), QDateTime::fromTime_t(_clientModel->getHeaderTipTime()));
setNumBlocks(_clientModel->getNumBlocks(), _clientModel->getLastBlockDate(), _clientModel->getVerificationProgress(NULL), false); setNumBlocks(_clientModel->getNumBlocks(), _clientModel->getLastBlockDate(), _clientModel->getVerificationProgress(NULL), false);
connect(_clientModel, SIGNAL(numBlocksChanged(int,QDateTime,double,bool)), this, SLOT(setNumBlocks(int,QDateTime,double,bool))); connect(_clientModel, SIGNAL(numBlocksChanged(int,QDateTime,double,bool)), this, SLOT(setNumBlocks(int,QDateTime,double,bool)));
@ -505,8 +506,6 @@ void BitcoinGUI::setClientModel(ClientModel *_clientModel)
// initialize the disable state of the tray icon with the current value in the model. // initialize the disable state of the tray icon with the current value in the model.
setTrayIconVisible(optionsModel->getHideTrayIcon()); setTrayIconVisible(optionsModel->getHideTrayIcon());
} }
modalOverlay->setKnownBestHeight(clientModel->getHeaderTipHeight(), QDateTime::fromTime_t(clientModel->getHeaderTipTime()));
} else { } else {
// Disable possibility to show main window via action // Disable possibility to show main window via action
toggleHideAction->setEnabled(false); toggleHideAction->setEnabled(false);

33
src/qt/clientmodel.cpp

@ -36,6 +36,8 @@ ClientModel::ClientModel(OptionsModel *_optionsModel, QObject *parent) :
banTableModel(0), banTableModel(0),
pollTimer(0) pollTimer(0)
{ {
cachedBestHeaderHeight = -1;
cachedBestHeaderTime = -1;
peerTableModel = new PeerTableModel(this); peerTableModel = new PeerTableModel(this);
banTableModel = new BanTableModel(this); banTableModel = new BanTableModel(this);
pollTimer = new QTimer(this); pollTimer = new QTimer(this);
@ -74,18 +76,28 @@ int ClientModel::getNumBlocks() const
int ClientModel::getHeaderTipHeight() const int ClientModel::getHeaderTipHeight() const
{ {
LOCK(cs_main); if (cachedBestHeaderHeight == -1) {
if (!pindexBestHeader) // make sure we initially populate the cache via a cs_main lock
return 0; // otherwise we need to wait for a tip update
return pindexBestHeader->nHeight; LOCK(cs_main);
if (pindexBestHeader) {
cachedBestHeaderHeight = pindexBestHeader->nHeight;
cachedBestHeaderTime = pindexBestHeader->GetBlockTime();
}
}
return cachedBestHeaderHeight;
} }
int64_t ClientModel::getHeaderTipTime() const int64_t ClientModel::getHeaderTipTime() const
{ {
LOCK(cs_main); if (cachedBestHeaderTime == -1) {
if (!pindexBestHeader) LOCK(cs_main);
return 0; if (pindexBestHeader) {
return pindexBestHeader->GetBlockTime(); cachedBestHeaderHeight = pindexBestHeader->nHeight;
cachedBestHeaderTime = pindexBestHeader->GetBlockTime();
}
}
return cachedBestHeaderTime;
} }
quint64 ClientModel::getTotalBytesRecv() const quint64 ClientModel::getTotalBytesRecv() const
@ -283,6 +295,11 @@ static void BlockTipChanged(ClientModel *clientmodel, bool initialSync, const CB
int64_t& nLastUpdateNotification = fHeader ? nLastHeaderTipUpdateNotification : nLastBlockTipUpdateNotification; int64_t& nLastUpdateNotification = fHeader ? nLastHeaderTipUpdateNotification : nLastBlockTipUpdateNotification;
if (fHeader) {
// cache best headers time and height to reduce future cs_main locks
clientmodel->cachedBestHeaderHeight = pIndex->nHeight;
clientmodel->cachedBestHeaderTime = pIndex->GetBlockTime();
}
// if we are in-sync, update the UI regardless of last update time // if we are in-sync, update the UI regardless of last update time
if (!initialSync || now - nLastUpdateNotification > MODEL_UPDATE_DELAY) { if (!initialSync || now - nLastUpdateNotification > MODEL_UPDATE_DELAY) {
//pass a async signal to the UI thread //pass a async signal to the UI thread

6
src/qt/clientmodel.h

@ -8,6 +8,8 @@
#include <QObject> #include <QObject>
#include <QDateTime> #include <QDateTime>
#include <atomic>
class AddressTableModel; class AddressTableModel;
class BanTableModel; class BanTableModel;
class OptionsModel; class OptionsModel;
@ -81,6 +83,10 @@ public:
QString formatClientStartupTime() const; QString formatClientStartupTime() const;
QString dataDir() const; QString dataDir() const;
// caches for the best header
mutable std::atomic<int> cachedBestHeaderHeight;
mutable std::atomic<int64_t> cachedBestHeaderTime;
private: private:
OptionsModel *optionsModel; OptionsModel *optionsModel;
PeerTableModel *peerTableModel; PeerTableModel *peerTableModel;

5
src/wallet/wallet.cpp

@ -2587,9 +2587,10 @@ bool CWallet::CreateTransaction(const vector<CRecipient>& vecSend, CWalletTx& wt
vector<CTxOut>::iterator position = txNew.vout.begin()+nChangePosInOut; vector<CTxOut>::iterator position = txNew.vout.begin()+nChangePosInOut;
txNew.vout.insert(position, newTxOut); txNew.vout.insert(position, newTxOut);
} }
} } else {
else
reservekey.ReturnKey(); reservekey.ReturnKey();
nChangePosInOut = -1;
}
// Fill vin // Fill vin
// //

Loading…
Cancel
Save