diff options
author | fanquake <fanquake@gmail.com> | 2023-05-12 09:51:42 +0100 |
---|---|---|
committer | fanquake <fanquake@gmail.com> | 2023-05-12 10:07:58 +0100 |
commit | 2e9fc2e353fe56e8e9ea2b2505aa69b9825122f7 (patch) | |
tree | c147e25bfec46db1f674306eaa2c27e20cb94d14 | |
parent | 7b7636ead18fd006815d867aa580b34e3e70731e (diff) | |
parent | a26ff204f0f0355749a1b61136437623b325f8fb (diff) |
Merge bitcoin/bitcoin#27624: [23.2] Backports for rc1v23.2rc1
a26ff204f0f0355749a1b61136437623b325f8fb doc: add initial release notes for v23.2 (fanquake)
60edfd57f1334497041655384238c43d3fc76184 doc: update manual pages for v23.2rc1 (fanquake)
b93814b234e4cf5ec95017b3cd54ce59c0aa59e8 doc: update version in bips.md to v23.2 (fanquake)
67bbe6d371fc33e0b17f2dc0a6a7faa5ab64dad0 build: bump version to v23.2rc1 (fanquake)
06731d19bc00820037961138c79cf3d3677e39ba net_processing: Boost inv trickle rate (Anthony Towns)
d0a2c87214d2a8ad350c86fd4a3202695569ca99 txmempool: have CompareDepthAndScore sort missing txs first (Anthony Towns)
ce8f812b0ac0905c26edd826c57886a08079b4a7 p2p: Avoid prematurely clearing download state for other peers (Suhas Daftuar)
Pull request description:
Final backports for `rc1`. Currently:
* https://github.com/bitcoin/bitcoin/pull/27608 (not a clean cherry-pick)
* https://github.com/bitcoin/bitcoin/pull/27610 (second commit is not clean)
ACKs for top commit:
achow101:
ACK a26ff204f0f0355749a1b61136437623b325f8fb
dergoegge:
ACK a26ff204f0f0355749a1b61136437623b325f8fb
ajtowns:
utACK a26ff204f0f0355749a1b61136437623b325f8fb
Tree-SHA512: 59e43ec4d5004b3543d5c0366c9dc8c5f8a6a777b147628ebc0c03aeb0846312a7780376ebf40f389e3403e4501ba2b70bb97925479670bee13c89e5b6925137
-rw-r--r-- | configure.ac | 4 | ||||
-rw-r--r-- | doc/bips.md | 2 | ||||
-rw-r--r-- | doc/man/bitcoin-cli.1 | 8 | ||||
-rw-r--r-- | doc/man/bitcoin-qt.1 | 10 | ||||
-rw-r--r-- | doc/man/bitcoin-tx.1 | 8 | ||||
-rw-r--r-- | doc/man/bitcoin-util.1 | 8 | ||||
-rw-r--r-- | doc/man/bitcoin-wallet.1 | 8 | ||||
-rw-r--r-- | doc/man/bitcoind.1 | 10 | ||||
-rw-r--r-- | doc/release-notes.md | 48 | ||||
-rw-r--r-- | doc/release-notes/release-notes-23.1.md | 90 | ||||
-rw-r--r-- | src/net_processing.cpp | 34 | ||||
-rw-r--r-- | src/txmempool.cpp | 11 |
12 files changed, 167 insertions, 74 deletions
diff --git a/configure.ac b/configure.ac index 313b847793..bde64da9fb 100644 --- a/configure.ac +++ b/configure.ac @@ -1,8 +1,8 @@ AC_PREREQ([2.69]) define(_CLIENT_VERSION_MAJOR, 23) -define(_CLIENT_VERSION_MINOR, 1) +define(_CLIENT_VERSION_MINOR, 2) define(_CLIENT_VERSION_BUILD, 0) -define(_CLIENT_VERSION_RC, 0) +define(_CLIENT_VERSION_RC, 1) define(_CLIENT_VERSION_IS_RELEASE, true) define(_COPYRIGHT_YEAR, 2022) define(_COPYRIGHT_HOLDERS,[The %s developers]) diff --git a/doc/bips.md b/doc/bips.md index 8a7ceaf7b3..95db722f8d 100644 --- a/doc/bips.md +++ b/doc/bips.md @@ -1,4 +1,4 @@ -BIPs that are implemented by Bitcoin Core (up-to-date up to **v23.1**): +BIPs that are implemented by Bitcoin Core (up-to-date up to **v23.2**): * [`BIP 9`](https://github.com/bitcoin/bips/blob/master/bip-0009.mediawiki): The changes allowing multiple soft-forks to be deployed in parallel have been implemented since **v0.12.1** ([PR #7575](https://github.com/bitcoin/bitcoin/pull/7575)) * [`BIP 11`](https://github.com/bitcoin/bips/blob/master/bip-0011.mediawiki): Multisig outputs are standard since **v0.6.0** ([PR #669](https://github.com/bitcoin/bitcoin/pull/669)). diff --git a/doc/man/bitcoin-cli.1 b/doc/man/bitcoin-cli.1 index 1ee6f42118..fe5abadfbd 100644 --- a/doc/man/bitcoin-cli.1 +++ b/doc/man/bitcoin-cli.1 @@ -1,7 +1,7 @@ -.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.49.2. -.TH BITCOIN-CLI "1" "December 2022" "bitcoin-cli v23.1.0" "User Commands" +.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.49.3. +.TH BITCOIN-CLI "1" "May 2023" "bitcoin-cli v23.2.0rc1" "User Commands" .SH NAME -bitcoin-cli \- manual page for bitcoin-cli v23.1.0 +bitcoin-cli \- manual page for bitcoin-cli v23.2.0rc1 .SH SYNOPSIS .B bitcoin-cli [\fI\,options\/\fR] \fI\,<command> \/\fR[\fI\,params\/\fR] \fI\,Send command to Bitcoin Core\/\fR @@ -15,7 +15,7 @@ bitcoin-cli \- manual page for bitcoin-cli v23.1.0 .B bitcoin-cli [\fI\,options\/\fR] \fI\,help <command> Get help for a command\/\fR .SH DESCRIPTION -Bitcoin Core RPC client version v23.1.0 +Bitcoin Core RPC client version v23.2.0rc1 .SH OPTIONS .HP \-? diff --git a/doc/man/bitcoin-qt.1 b/doc/man/bitcoin-qt.1 index 9536929fde..60b7981d0f 100644 --- a/doc/man/bitcoin-qt.1 +++ b/doc/man/bitcoin-qt.1 @@ -1,12 +1,12 @@ -.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.49.2. -.TH BITCOIN-QT "1" "December 2022" "bitcoin-qt v23.1.0" "User Commands" +.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.49.3. +.TH BITCOIN-QT "1" "May 2023" "bitcoin-qt v23.2.0rc1" "User Commands" .SH NAME -bitcoin-qt \- manual page for bitcoin-qt v23.1.0 +bitcoin-qt \- manual page for bitcoin-qt v23.2.0rc1 .SH SYNOPSIS .B bitcoin-qt [\fI\,command-line options\/\fR] .SH DESCRIPTION -Bitcoin Core version v23.1.0 +Bitcoin Core version v23.2.0rc1 .SH OPTIONS .HP \-? @@ -115,7 +115,7 @@ Do not keep transactions in the mempool longer than <n> hours (default: .HP \fB\-par=\fR<n> .IP -Set the number of script verification threads (\fB\-6\fR to 15, 0 = auto, <0 = +Set the number of script verification threads (\fB\-10\fR to 15, 0 = auto, <0 = leave that many cores free, default: 0) .HP \fB\-persistmempool\fR diff --git a/doc/man/bitcoin-tx.1 b/doc/man/bitcoin-tx.1 index e2a4417a2b..fd2540c5aa 100644 --- a/doc/man/bitcoin-tx.1 +++ b/doc/man/bitcoin-tx.1 @@ -1,7 +1,7 @@ -.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.49.2. -.TH BITCOIN-TX "1" "December 2022" "bitcoin-tx v23.1.0" "User Commands" +.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.49.3. +.TH BITCOIN-TX "1" "May 2023" "bitcoin-tx v23.2.0rc1" "User Commands" .SH NAME -bitcoin-tx \- manual page for bitcoin-tx v23.1.0 +bitcoin-tx \- manual page for bitcoin-tx v23.2.0rc1 .SH SYNOPSIS .B bitcoin-tx [\fI\,options\/\fR] \fI\,<hex-tx> \/\fR[\fI\,commands\/\fR] \fI\,Update hex-encoded bitcoin transaction\/\fR @@ -9,7 +9,7 @@ bitcoin-tx \- manual page for bitcoin-tx v23.1.0 .B bitcoin-tx [\fI\,options\/\fR] \fI\,-create \/\fR[\fI\,commands\/\fR] \fI\,Create hex-encoded bitcoin transaction\/\fR .SH DESCRIPTION -Bitcoin Core bitcoin\-tx utility version v23.1.0 +Bitcoin Core bitcoin\-tx utility version v23.2.0rc1 .SH OPTIONS .HP \-? diff --git a/doc/man/bitcoin-util.1 b/doc/man/bitcoin-util.1 index e9ec7b427c..15bac7951b 100644 --- a/doc/man/bitcoin-util.1 +++ b/doc/man/bitcoin-util.1 @@ -1,12 +1,12 @@ -.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.49.2. -.TH BITCOIN-UTIL "1" "December 2022" "bitcoin-util v23.1.0" "User Commands" +.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.49.3. +.TH BITCOIN-UTIL "1" "May 2023" "bitcoin-util v23.2.0rc1" "User Commands" .SH NAME -bitcoin-util \- manual page for bitcoin-util v23.1.0 +bitcoin-util \- manual page for bitcoin-util v23.2.0rc1 .SH SYNOPSIS .B bitcoin-util [\fI\,options\/\fR] [\fI\,commands\/\fR] \fI\,Do stuff\/\fR .SH DESCRIPTION -Bitcoin Core bitcoin\-util utility version v23.1.0 +Bitcoin Core bitcoin\-util utility version v23.2.0rc1 .SH OPTIONS .HP \-? diff --git a/doc/man/bitcoin-wallet.1 b/doc/man/bitcoin-wallet.1 index 028f0a753f..2b5f08e301 100644 --- a/doc/man/bitcoin-wallet.1 +++ b/doc/man/bitcoin-wallet.1 @@ -1,9 +1,9 @@ -.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.49.2. -.TH BITCOIN-WALLET "1" "December 2022" "bitcoin-wallet v23.1.0" "User Commands" +.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.49.3. +.TH BITCOIN-WALLET "1" "May 2023" "bitcoin-wallet v23.2.0rc1" "User Commands" .SH NAME -bitcoin-wallet \- manual page for bitcoin-wallet v23.1.0 +bitcoin-wallet \- manual page for bitcoin-wallet v23.2.0rc1 .SH DESCRIPTION -Bitcoin Core bitcoin\-wallet version v23.1.0 +Bitcoin Core bitcoin\-wallet version v23.2.0rc1 .PP bitcoin\-wallet is an offline tool for creating and interacting with Bitcoin Core wallet files. By default bitcoin\-wallet will act on wallets in the default mainnet wallet directory in the datadir. diff --git a/doc/man/bitcoind.1 b/doc/man/bitcoind.1 index 63be12b2df..f8591c4567 100644 --- a/doc/man/bitcoind.1 +++ b/doc/man/bitcoind.1 @@ -1,12 +1,12 @@ -.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.49.2. -.TH BITCOIND "1" "December 2022" "bitcoind v23.1.0" "User Commands" +.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.49.3. +.TH BITCOIND "1" "May 2023" "bitcoind v23.2.0rc1" "User Commands" .SH NAME -bitcoind \- manual page for bitcoind v23.1.0 +bitcoind \- manual page for bitcoind v23.2.0rc1 .SH SYNOPSIS .B bitcoind [\fI\,options\/\fR] \fI\,Start Bitcoin Core\/\fR .SH DESCRIPTION -Bitcoin Core version v23.1.0 +Bitcoin Core version v23.2.0rc1 .SH OPTIONS .HP \-? @@ -115,7 +115,7 @@ Do not keep transactions in the mempool longer than <n> hours (default: .HP \fB\-par=\fR<n> .IP -Set the number of script verification threads (\fB\-6\fR to 15, 0 = auto, <0 = +Set the number of script verification threads (\fB\-10\fR to 15, 0 = auto, <0 = leave that many cores free, default: 0) .HP \fB\-persistmempool\fR diff --git a/doc/release-notes.md b/doc/release-notes.md index 31d9b7f068..4b1d0f0040 100644 --- a/doc/release-notes.md +++ b/doc/release-notes.md @@ -1,9 +1,9 @@ -23.1 Release Notes +23.2rc1 Release Notes ================== -Bitcoin Core version 23.1 is now available from: +Bitcoin Core version 23.2rc1 is now available from: - <https://bitcoincore.org/bin/bitcoin-core-23.1/> + <https://bitcoincore.org/bin/bitcoin-core-23.2/test.rc1/> This release includes new features, various bug fixes and performance improvements, as well as updated translations. @@ -39,52 +39,34 @@ unsupported systems. ### P2P -- #25314 p2p: always set nTime for self-advertisements - -### RPC and other APIs - -- #25220 rpc: fix incorrect warning for address type p2sh-segwit in createmultisig -- #25237 rpc: Capture UniValue by ref for rpcdoccheck -- #25983 Prevent data race for pathHandlers -- #26275 Fix crash on deriveaddresses when index is 2147483647 (2^31-1) +- #26909 net: prevent peers.dat corruptions by only serializing once +- #27608 p2p: Avoid prematurely clearing download state for other peers +- #27610 Improve performance of p2p inv to send queues ### Build system -- #25201 windeploy: Renewed windows code signing certificate -- #25788 guix: patch NSIS to remove .reloc sections from installer stubs -- #25861 guix: use --build={arch}-guix-linux-gnu in cross toolchain -- #25985 Revert "build: Use Homebrew's sqlite package if it is available" - -### GUI - -- #24668 build, qt: bump Qt5 version to 5.15.3 -- gui#631 Disallow encryption of watchonly wallets -- gui#680 Fixes MacOS 13 segfault by preventing certain notifications - -### Tests - -- #24454 tests: Fix calculation of external input weights +- #25436 build: suppress array-bounds errors in libxkbcommon +- #25763 bdb: disable Werror for format-security +- #26944 depends: fix systemtap download URL +- #27462 depends: fix compiling bdb with clang-16 on aarch64 ### Miscellaneous -- #26321 Adjust .tx/config for new Transifex CLI +- #25444 ci: macOS task imrovements +- #26388 ci: Use macos-ventura-xcode:14.1 image for "macOS native" task +- #26924 refactor: Add missing includes to fix gcc-13 compile error Credits ======= Thanks to everyone who directly contributed to this release: -- Andrew Chow -- brunoerg +- Anthony Towns - Hennadii Stepanov -- John Moffett - MacroFake - Martin Zumsande - Michael Ford -- muxator -- Pavol Rusnak -- Sebastian Falbesoner -- W. J. van der Laan +- Suhas Daftuar As well as to everyone that helped with translations on [Transifex](https://www.transifex.com/bitcoin/bitcoin/). diff --git a/doc/release-notes/release-notes-23.1.md b/doc/release-notes/release-notes-23.1.md new file mode 100644 index 0000000000..31d9b7f068 --- /dev/null +++ b/doc/release-notes/release-notes-23.1.md @@ -0,0 +1,90 @@ +23.1 Release Notes +================== + +Bitcoin Core version 23.1 is now available from: + + <https://bitcoincore.org/bin/bitcoin-core-23.1/> + +This release includes new features, various bug fixes and performance +improvements, as well as updated translations. + +Please report bugs using the issue tracker at GitHub: + + <https://github.com/bitcoin/bitcoin/issues> + +To receive security and update notifications, please subscribe to: + + <https://bitcoincore.org/en/list/announcements/join/> + +How to Upgrade +============== + +If you are running an older version, shut it down. Wait until it has completely +shut down (which might take a few minutes in some cases), then run the +installer (on Windows) or just copy over `/Applications/Bitcoin-Qt` (on macOS) +or `bitcoind`/`bitcoin-qt` (on Linux). + +Upgrading directly from a version of Bitcoin Core that has reached its EOL is +possible, but it might take some time if the data directory needs to be migrated. Old +wallet versions of Bitcoin Core are generally supported. + +Compatibility +============== + +Bitcoin Core is supported and extensively tested on operating systems +using the Linux kernel, macOS 10.15+, and Windows 7 and newer. Bitcoin +Core should also work on most other Unix-like systems but is not as +frequently tested on them. It is not recommended to use Bitcoin Core on +unsupported systems. + +### P2P + +- #25314 p2p: always set nTime for self-advertisements + +### RPC and other APIs + +- #25220 rpc: fix incorrect warning for address type p2sh-segwit in createmultisig +- #25237 rpc: Capture UniValue by ref for rpcdoccheck +- #25983 Prevent data race for pathHandlers +- #26275 Fix crash on deriveaddresses when index is 2147483647 (2^31-1) + +### Build system + +- #25201 windeploy: Renewed windows code signing certificate +- #25788 guix: patch NSIS to remove .reloc sections from installer stubs +- #25861 guix: use --build={arch}-guix-linux-gnu in cross toolchain +- #25985 Revert "build: Use Homebrew's sqlite package if it is available" + +### GUI + +- #24668 build, qt: bump Qt5 version to 5.15.3 +- gui#631 Disallow encryption of watchonly wallets +- gui#680 Fixes MacOS 13 segfault by preventing certain notifications + +### Tests + +- #24454 tests: Fix calculation of external input weights + +### Miscellaneous + +- #26321 Adjust .tx/config for new Transifex CLI + +Credits +======= + +Thanks to everyone who directly contributed to this release: + +- Andrew Chow +- brunoerg +- Hennadii Stepanov +- John Moffett +- MacroFake +- Martin Zumsande +- Michael Ford +- muxator +- Pavol Rusnak +- Sebastian Falbesoner +- W. J. van der Laan + +As well as to everyone that helped with translations on +[Transifex](https://www.transifex.com/bitcoin/bitcoin/). diff --git a/src/net_processing.cpp b/src/net_processing.cpp index aee1e4c30c..0e75ec99ec 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -541,8 +541,11 @@ private: /** Remove this block from our tracked requested blocks. Called if: * - the block has been received from a peer * - the request for the block has timed out + * If "from_peer" is specified, then only remove the block if it is in + * flight from that peer (to avoid one peer's network traffic from + * affecting another's state). */ - void RemoveBlockRequest(const uint256& hash) EXCLUSIVE_LOCKS_REQUIRED(cs_main); + void RemoveBlockRequest(const uint256& hash, std::optional<NodeId> from_peer) EXCLUSIVE_LOCKS_REQUIRED(cs_main); /* Mark a block as in flight * Returns false, still setting pit, if the block was already in flight from the same peer @@ -853,7 +856,7 @@ bool PeerManagerImpl::IsBlockRequested(const uint256& hash) return mapBlocksInFlight.find(hash) != mapBlocksInFlight.end(); } -void PeerManagerImpl::RemoveBlockRequest(const uint256& hash) +void PeerManagerImpl::RemoveBlockRequest(const uint256& hash, std::optional<NodeId> from_peer) { auto it = mapBlocksInFlight.find(hash); if (it == mapBlocksInFlight.end()) { @@ -862,6 +865,12 @@ void PeerManagerImpl::RemoveBlockRequest(const uint256& hash) } auto [node_id, list_it] = it->second; + + if (from_peer && node_id != *from_peer) { + // Block was requested by another peer + return; + } + CNodeState *state = State(node_id); assert(state != nullptr); @@ -897,7 +906,7 @@ bool PeerManagerImpl::BlockRequested(NodeId nodeid, const CBlockIndex& block, st } // Make sure it's not listed somewhere already. - RemoveBlockRequest(hash); + RemoveBlockRequest(hash, std::nullopt); std::list<QueuedBlock>::iterator it = state->vBlocksInFlight.insert(state->vBlocksInFlight.end(), {&block, std::unique_ptr<PartiallyDownloadedBlock>(pit ? new PartiallyDownloadedBlock(&m_mempool) : nullptr)}); @@ -2545,6 +2554,11 @@ void PeerManagerImpl::ProcessBlock(CNode& node, const std::shared_ptr<const CBlo m_chainman.ProcessNewBlock(m_chainparams, block, force_processing, &new_block); if (new_block) { node.m_last_block_time = GetTime<std::chrono::seconds>(); + // In case this block came from a different peer than we requested + // from, we can erase the block request now anyway (as we just stored + // this block to disk). + LOCK(cs_main); + RemoveBlockRequest(block->GetHash(), std::nullopt); } else { LOCK(cs_main); mapBlockSource.erase(block->GetHash()); @@ -3604,7 +3618,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type, PartiallyDownloadedBlock& partialBlock = *(*queuedBlockIt)->partialBlock; ReadStatus status = partialBlock.InitData(cmpctblock, vExtraTxnForCompact); if (status == READ_STATUS_INVALID) { - RemoveBlockRequest(pindex->GetBlockHash()); // Reset in-flight state in case Misbehaving does not result in a disconnect + RemoveBlockRequest(pindex->GetBlockHash(), pfrom.GetId()); // Reset in-flight state in case Misbehaving does not result in a disconnect Misbehaving(pfrom.GetId(), 100, "invalid compact block"); return; } else if (status == READ_STATUS_FAILED) { @@ -3699,7 +3713,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type, // process from some other peer. We do this after calling // ProcessNewBlock so that a malleated cmpctblock announcement // can't be used to interfere with block relay. - RemoveBlockRequest(pblock->GetHash()); + RemoveBlockRequest(pblock->GetHash(), std::nullopt); } } return; @@ -3731,7 +3745,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type, PartiallyDownloadedBlock& partialBlock = *it->second.second->partialBlock; ReadStatus status = partialBlock.FillBlock(*pblock, resp.txn); if (status == READ_STATUS_INVALID) { - RemoveBlockRequest(resp.blockhash); // Reset in-flight state in case Misbehaving does not result in a disconnect + RemoveBlockRequest(resp.blockhash, pfrom.GetId()); // Reset in-flight state in case Misbehaving does not result in a disconnect Misbehaving(pfrom.GetId(), 100, "invalid compact block/non-matching block transactions"); return; } else if (status == READ_STATUS_FAILED) { @@ -3757,7 +3771,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type, // though the block was successfully read, and rely on the // handling in ProcessNewBlock to ensure the block index is // updated, etc. - RemoveBlockRequest(resp.blockhash); // it is now an empty pointer + RemoveBlockRequest(resp.blockhash, pfrom.GetId()); // it is now an empty pointer fBlockRead = true; // mapBlockSource is used for potentially punishing peers and // updating which peers send us compact blocks, so the race @@ -3825,7 +3839,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type, // Always process the block if we requested it, since we may // need it even when it's not a candidate for a new best tip. forceProcessing = IsBlockRequested(hash); - RemoveBlockRequest(hash); + RemoveBlockRequest(hash, pfrom.GetId()); // mapBlockSource is only used for punishing peers and setting // which peers send us compact blocks, so the race between here and // cs_main in ProcessNewBlock is fine. @@ -4876,7 +4890,9 @@ bool PeerManagerImpl::SendMessages(CNode* pto) // especially since we have many peers and some will draw much shorter delays. unsigned int nRelayedTransactions = 0; LOCK(pto->m_tx_relay->cs_filter); - while (!vInvTx.empty() && nRelayedTransactions < INVENTORY_BROADCAST_MAX) { + size_t broadcast_max{INVENTORY_BROADCAST_MAX + (pto->m_tx_relay->setInventoryTxToSend.size()/1000)*5}; + broadcast_max = std::min<size_t>(1000, broadcast_max); + while (!vInvTx.empty() && nRelayedTransactions < broadcast_max) { // Fetch the top element from the heap std::pop_heap(vInvTx.begin(), vInvTx.end(), compareInvMempoolOrder); std::set<uint256>::iterator it = vInvTx.back(); diff --git a/src/txmempool.cpp b/src/txmempool.cpp index fb5652d0a0..e78969c69d 100644 --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -831,11 +831,16 @@ void CTxMemPool::check(const CCoinsViewCache& active_coins_tip, int64_t spendhei bool CTxMemPool::CompareDepthAndScore(const uint256& hasha, const uint256& hashb, bool wtxid) { + /* Return `true` if hasha should be considered sooner than hashb. Namely when: + * a is not in the mempool, but b is + * both are in the mempool and a has fewer ancestors than b + * both are in the mempool and a has a higher score than b + */ LOCK(cs); - indexed_transaction_set::const_iterator i = wtxid ? get_iter_from_wtxid(hasha) : mapTx.find(hasha); - if (i == mapTx.end()) return false; indexed_transaction_set::const_iterator j = wtxid ? get_iter_from_wtxid(hashb) : mapTx.find(hashb); - if (j == mapTx.end()) return true; + if (j == mapTx.end()) return false; + indexed_transaction_set::const_iterator i = wtxid ? get_iter_from_wtxid(hasha) : mapTx.find(hasha); + if (i == mapTx.end()) return true; uint64_t counta = i->GetCountWithAncestors(); uint64_t countb = j->GetCountWithAncestors(); if (counta == countb) { |