aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xcontrib/devtools/copyright_header.py47
-rw-r--r--doc/release-notes.md8
-rw-r--r--src/coins.h12
-rw-r--r--src/net.h14
-rw-r--r--src/rpc/server.cpp4
-rw-r--r--src/streams.h32
-rw-r--r--src/sync.cpp8
-rw-r--r--src/validation.h2
-rw-r--r--src/wallet/rpcdump.cpp6
-rw-r--r--src/wallet/wallet.h16
-rw-r--r--test/functional/README.md2
-rwxr-xr-xtest/functional/example_test.py2
-rwxr-xr-xtest/functional/p2p_segwit.py2
13 files changed, 79 insertions, 76 deletions
diff --git a/contrib/devtools/copyright_header.py b/contrib/devtools/copyright_header.py
index 6d7a592f01..f2987f2260 100755
--- a/contrib/devtools/copyright_header.py
+++ b/contrib/devtools/copyright_header.py
@@ -48,15 +48,22 @@ def applies_to_file(filename):
# obtain list of files in repo according to INCLUDE and EXCLUDE
################################################################################
-GIT_LS_CMD = 'git ls-files'
+GIT_LS_CMD = 'git ls-files --full-name'.split(' ')
+GIT_TOPLEVEL_CMD = 'git rev-parse --show-toplevel'.split(' ')
-def call_git_ls():
- out = subprocess.check_output(GIT_LS_CMD.split(' '))
+def call_git_ls(base_directory):
+ out = subprocess.check_output([*GIT_LS_CMD, base_directory])
return [f for f in out.decode("utf-8").split('\n') if f != '']
-def get_filenames_to_examine():
- filenames = call_git_ls()
- return sorted([filename for filename in filenames if
+def call_git_toplevel():
+ "Returns the absolute path to the project root"
+ return subprocess.check_output(GIT_TOPLEVEL_CMD).strip().decode("utf-8")
+
+def get_filenames_to_examine(base_directory):
+ "Returns an array of absolute paths to any project files in the base_directory that pass the include/exclude filters"
+ root = call_git_toplevel()
+ filenames = call_git_ls(base_directory)
+ return sorted([os.path.join(root, filename) for filename in filenames if
applies_to_file(filename)])
################################################################################
@@ -83,24 +90,12 @@ def compile_copyright_regex(copyright_style, year_style, name):
EXPECTED_HOLDER_NAMES = [
"Satoshi Nakamoto\n",
"The Bitcoin Core developers\n",
- "The Bitcoin Core developers \n",
"Bitcoin Core Developers\n",
- "the Bitcoin Core developers\n",
- "The Bitcoin developers\n",
- "The LevelDB Authors\. All rights reserved\.\n",
"BitPay Inc\.\n",
- "BitPay, Inc\.\n",
"University of Illinois at Urbana-Champaign\.\n",
- "MarcoFalke\n",
"Pieter Wuille\n",
- "Pieter Wuille +\*\n",
- "Pieter Wuille, Gregory Maxwell +\*\n",
- "Pieter Wuille, Andrew Poelstra +\*\n",
- "Andrew Poelstra +\*\n",
"Wladimir J. van der Laan\n",
"Jeff Garzik\n",
- "Diederik Huys, Pieter Wuille +\*\n",
- "Thomas Daede, Cory Fields +\*\n",
"Jan-Klaas Kollhof\n",
"Sam Rushing\n",
"ArtForz -- public domain half-a-node\n",
@@ -146,7 +141,7 @@ def file_has_without_c_style_copyright_for_holder(contents, holder_name):
################################################################################
def read_file(filename):
- return open(os.path.abspath(filename), 'r', encoding="utf8").read()
+ return open(filename, 'r', encoding="utf8").read()
def gather_file_info(filename):
info = {}
@@ -260,12 +255,9 @@ def print_report(file_infos, verbose):
print(SEPARATOR)
def exec_report(base_directory, verbose):
- original_cwd = os.getcwd()
- os.chdir(base_directory)
- filenames = get_filenames_to_examine()
+ filenames = get_filenames_to_examine(base_directory)
file_infos = [gather_file_info(f) for f in filenames]
print_report(file_infos, verbose)
- os.chdir(original_cwd)
################################################################################
# report cmd
@@ -325,13 +317,13 @@ def get_most_recent_git_change_year(filename):
################################################################################
def read_file_lines(filename):
- f = open(os.path.abspath(filename), 'r', encoding="utf8")
+ f = open(filename, 'r', encoding="utf8")
file_lines = f.readlines()
f.close()
return file_lines
def write_file_lines(filename, file_lines):
- f = open(os.path.abspath(filename), 'w', encoding="utf8")
+ f = open(filename, 'w', encoding="utf8")
f.write(''.join(file_lines))
f.close()
@@ -399,11 +391,8 @@ def update_updatable_copyright(filename):
"Copyright updated! -> %s" % last_git_change_year)
def exec_update_header_year(base_directory):
- original_cwd = os.getcwd()
- os.chdir(base_directory)
- for filename in get_filenames_to_examine():
+ for filename in get_filenames_to_examine(base_directory):
update_updatable_copyright(filename)
- os.chdir(original_cwd)
################################################################################
# update cmd
diff --git a/doc/release-notes.md b/doc/release-notes.md
index c21a153a25..9e04f11635 100644
--- a/doc/release-notes.md
+++ b/doc/release-notes.md
@@ -111,6 +111,14 @@ Configuration option changes
ambiguous whether the hash character is meant for the password or as a
comment.
+- The `whitelistforcerelay` option is used to relay transactions from
+ whitelisted peers even when not accepted to the mempool. This option now
+ defaults to being off, so that changes in policy and disconnect/ban behavior
+ will not cause a node that is whitelisting another to be dropped by peers.
+ Users can still explicitly enable this behavior with the command line option
+ (and may want to consider letting the Bitcoin Core project know about their
+ use-case, as this feature could be deprecated in the future).
+
Documentation
-------------
diff --git a/src/coins.h b/src/coins.h
index 94493453f0..d39ebf9062 100644
--- a/src/coins.h
+++ b/src/coins.h
@@ -298,17 +298,17 @@ private:
};
//! Utility function to add all of a transaction's outputs to a cache.
-// When check is false, this assumes that overwrites are only possible for coinbase transactions.
-// When check is true, the underlying view may be queried to determine whether an addition is
-// an overwrite.
+//! When check is false, this assumes that overwrites are only possible for coinbase transactions.
+//! When check is true, the underlying view may be queried to determine whether an addition is
+//! an overwrite.
// TODO: pass in a boolean to limit these possible overwrites to known
// (pre-BIP34) cases.
void AddCoins(CCoinsViewCache& cache, const CTransaction& tx, int nHeight, bool check = false);
//! Utility function to find any unspent output with a given txid.
-// This function can be quite expensive because in the event of a transaction
-// which is not found in the cache, it can cause up to MAX_OUTPUTS_PER_BLOCK
-// lookups to database, so it should be used with care.
+//! This function can be quite expensive because in the event of a transaction
+//! which is not found in the cache, it can cause up to MAX_OUTPUTS_PER_BLOCK
+//! lookups to database, so it should be used with care.
const Coin& AccessByTxid(const CCoinsViewCache& cache, const uint256& txid);
#endif // BITCOIN_COINS_H
diff --git a/src/net.h b/src/net.h
index 9c477f6db6..4449a36ecd 100644
--- a/src/net.h
+++ b/src/net.h
@@ -273,17 +273,17 @@ public:
void SetMaxOutboundTimeframe(uint64_t timeframe);
uint64_t GetMaxOutboundTimeframe();
- //!check if the outbound target is reached
- // if param historicalBlockServingLimit is set true, the function will
- // response true if the limit for serving historical blocks has been reached
+ //! check if the outbound target is reached
+ //! if param historicalBlockServingLimit is set true, the function will
+ //! response true if the limit for serving historical blocks has been reached
bool OutboundTargetReached(bool historicalBlockServingLimit);
- //!response the bytes left in the current max outbound cycle
- // in case of no limit, it will always response 0
+ //! response the bytes left in the current max outbound cycle
+ //! in case of no limit, it will always response 0
uint64_t GetOutboundTargetBytesLeft();
- //!response the time in second left in the current max outbound cycle
- // in case of no limit, it will always response 0
+ //! response the time in second left in the current max outbound cycle
+ //! in case of no limit, it will always response 0
uint64_t GetMaxOutboundTimeLeftInCycle();
uint64_t GetTotalBytesRecv();
diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp
index 6b31a1b016..2ed74547b9 100644
--- a/src/rpc/server.cpp
+++ b/src/rpc/server.cpp
@@ -1,5 +1,5 @@
// Copyright (c) 2010 Satoshi Nakamoto
-// Copyright (c) 2009-2018 The Bitcoin Core developers
+// Copyright (c) 2009-2019 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
@@ -51,7 +51,7 @@ struct RPCCommandExecution
explicit RPCCommandExecution(const std::string& method)
{
LOCK(g_rpc_server_info.mutex);
- it = g_rpc_server_info.active_commands.insert(g_rpc_server_info.active_commands.cend(), {method, GetTimeMicros()});
+ it = g_rpc_server_info.active_commands.insert(g_rpc_server_info.active_commands.end(), {method, GetTimeMicros()});
}
~RPCCommandExecution()
{
diff --git a/src/streams.h b/src/streams.h
index 0809c96be1..4e600f1826 100644
--- a/src/streams.h
+++ b/src/streams.h
@@ -139,7 +139,7 @@ private:
public:
- /*
+ /**
* @param[in] type Serialization Type
* @param[in] version Serialization Version (including any flags)
* @param[in] data Referenced byte vector to overwrite/append
@@ -153,7 +153,7 @@ public:
}
}
- /*
+ /**
* (other params same as above)
* @param[in] args A list of items to deserialize starting at pos.
*/
@@ -715,15 +715,15 @@ private:
const int nType;
const int nVersion;
- FILE *src; // source file
- uint64_t nSrcPos; // how many bytes have been read from source
- uint64_t nReadPos; // how many bytes have been read from this
- uint64_t nReadLimit; // up to which position we're allowed to read
- uint64_t nRewind; // how many bytes we guarantee to rewind
- std::vector<char> vchBuf; // the buffer
+ FILE *src; //!< source file
+ uint64_t nSrcPos; //!< how many bytes have been read from source
+ uint64_t nReadPos; //!< how many bytes have been read from this
+ uint64_t nReadLimit; //!< up to which position we're allowed to read
+ uint64_t nRewind; //!< how many bytes we guarantee to rewind
+ std::vector<char> vchBuf; //!< the buffer
protected:
- // read data from the source to fill the buffer
+ //! read data from the source to fill the buffer
bool Fill() {
unsigned int pos = nSrcPos % vchBuf.size();
unsigned int readNow = vchBuf.size() - pos;
@@ -768,12 +768,12 @@ public:
}
}
- // check whether we're at the end of the source file
+ //! check whether we're at the end of the source file
bool eof() const {
return nReadPos == nSrcPos && feof(src);
}
- // read a number of bytes
+ //! read a number of bytes
void read(char *pch, size_t nSize) {
if (nSize + nReadPos > nReadLimit)
throw std::ios_base::failure("Read attempted past buffer limit");
@@ -795,12 +795,12 @@ public:
}
}
- // return the current reading position
+ //! return the current reading position
uint64_t GetPos() const {
return nReadPos;
}
- // rewind to a given reading position
+ //! rewind to a given reading position
bool SetPos(uint64_t nPos) {
nReadPos = nPos;
if (nReadPos + nRewind < nSrcPos) {
@@ -826,8 +826,8 @@ public:
return true;
}
- // prevent reading beyond a certain position
- // no argument removes the limit
+ //! prevent reading beyond a certain position
+ //! no argument removes the limit
bool SetLimit(uint64_t nPos = std::numeric_limits<uint64_t>::max()) {
if (nPos < nReadPos)
return false;
@@ -842,7 +842,7 @@ public:
return (*this);
}
- // search for a given byte in the stream, and remain positioned on it
+ //! search for a given byte in the stream, and remain positioned on it
void FindByte(char ch) {
while (true) {
if (nReadPos == nSrcPos)
diff --git a/src/sync.cpp b/src/sync.cpp
index 30811f5f89..23ca866e53 100644
--- a/src/sync.cpp
+++ b/src/sync.cpp
@@ -73,7 +73,11 @@ struct LockData {
LockOrders lockorders;
InvLockOrders invlockorders;
std::mutex dd_mutex;
-} static lockdata;
+};
+LockData& GetLockData() {
+ static LockData lockdata;
+ return lockdata;
+}
static thread_local LockStack g_lockstack;
@@ -109,6 +113,7 @@ static void potential_deadlock_detected(const std::pair<void*, void*>& mismatch,
static void push_lock(void* c, const CLockLocation& locklocation)
{
+ LockData& lockdata = GetLockData();
std::lock_guard<std::mutex> lock(lockdata.dd_mutex);
g_lockstack.push_back(std::make_pair(c, locklocation));
@@ -173,6 +178,7 @@ void AssertLockNotHeldInternal(const char* pszName, const char* pszFile, int nLi
void DeleteLock(void* cs)
{
+ LockData& lockdata = GetLockData();
if (!lockdata.available) {
// We're already shutting down.
return;
diff --git a/src/validation.h b/src/validation.h
index b5548a9293..c0ffc9b0e4 100644
--- a/src/validation.h
+++ b/src/validation.h
@@ -50,7 +50,7 @@ struct LockPoints;
/** Default for -whitelistrelay. */
static const bool DEFAULT_WHITELISTRELAY = true;
/** Default for -whitelistforcerelay. */
-static const bool DEFAULT_WHITELISTFORCERELAY = true;
+static const bool DEFAULT_WHITELISTFORCERELAY = false;
/** Default for -minrelaytxfee, minimum relay fee for transactions */
static const unsigned int DEFAULT_MIN_RELAY_TX_FEE = 1000;
//! -maxtxfee default
diff --git a/src/wallet/rpcdump.cpp b/src/wallet/rpcdump.cpp
index 7da92ca226..41b72870c7 100644
--- a/src/wallet/rpcdump.cpp
+++ b/src/wallet/rpcdump.cpp
@@ -860,9 +860,9 @@ struct ImportData
enum class ScriptContext
{
- TOP, //! Top-level scriptPubKey
- P2SH, //! P2SH redeemScript
- WITNESS_V0, //! P2WSH witnessScript
+ TOP, //!< Top-level scriptPubKey
+ P2SH, //!< P2SH redeemScript
+ WITNESS_V0, //!< P2WSH witnessScript
};
// Analyse the provided scriptPubKey, determining which keys and which redeem scripts from the ImportData struct are needed to spend it, and mark them as used.
diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h
index 6872fbad2d..937b727793 100644
--- a/src/wallet/wallet.h
+++ b/src/wallet/wallet.h
@@ -35,8 +35,8 @@
#include <vector>
//! Responsible for reading and validating the -wallet arguments and verifying the wallet database.
-// This function will perform salvage on the wallet if requested, as long as only one wallet is
-// being loaded (WalletParameterInteraction forbids -salvagewallet, -zapwallettxes or -upgradewallet with multiwallet).
+//! This function will perform salvage on the wallet if requested, as long as only one wallet is
+//! being loaded (WalletParameterInteraction forbids -salvagewallet, -zapwallettxes or -upgradewallet with multiwallet).
bool VerifyWallets(interfaces::Chain& chain, const std::vector<std::string>& wallet_files);
//! Load wallet databases.
@@ -55,10 +55,10 @@ void StopWallets();
void UnloadWallets();
//! Explicitly unload and delete the wallet.
-// Blocks the current thread after signaling the unload intent so that all
-// wallet clients release the wallet.
-// Note that, when blocking is not required, the wallet is implicitly unloaded
-// by the shared pointer deleter.
+//! Blocks the current thread after signaling the unload intent so that all
+//! wallet clients release the wallet.
+//! Note that, when blocking is not required, the wallet is implicitly unloaded
+//! by the shared pointer deleter.
void UnloadWallet(std::shared_ptr<CWallet>&& wallet);
bool AddWallet(const std::shared_ptr<CWallet>& wallet);
@@ -588,8 +588,8 @@ public:
int64_t nTimeCreated;
int64_t nTimeExpires;
std::string strComment;
- //! todo: add something to note what created it (user, getnewaddress, change)
- //! maybe should have a map<string, string> property map
+ // todo: add something to note what created it (user, getnewaddress, change)
+ // maybe should have a map<string, string> property map
explicit CWalletKey(int64_t nExpires=0);
diff --git a/test/functional/README.md b/test/functional/README.md
index bce0d5db2e..628c77eb11 100644
--- a/test/functional/README.md
+++ b/test/functional/README.md
@@ -26,7 +26,7 @@ don't have test cases for.
The Travis linter also checks this, but [possibly not in all cases](https://github.com/bitcoin/bitcoin/pull/14884#discussion_r239585126).
- See [the python lint script](/test/lint/lint-python.sh) that checks for violations that
could lead to bugs and issues in the test code.
-- Avoid wildcard imports where possible
+- Avoid wildcard imports
- Use a module-level docstring to describe what the test is testing, and how it
is testing it.
- When subclassing the BitcoinTestFramwork, place overrides for the
diff --git a/test/functional/example_test.py b/test/functional/example_test.py
index be3544ee74..f367e4fca8 100755
--- a/test/functional/example_test.py
+++ b/test/functional/example_test.py
@@ -13,7 +13,7 @@ is testing and *how* it's being tested
# libraries then local imports).
from collections import defaultdict
-# Avoid wildcard * imports if possible
+# Avoid wildcard * imports
from test_framework.blocktools import (create_block, create_coinbase)
from test_framework.messages import CInv
from test_framework.mininode import (
diff --git a/test/functional/p2p_segwit.py b/test/functional/p2p_segwit.py
index d95da227e5..8f8e89cf15 100755
--- a/test/functional/p2p_segwit.py
+++ b/test/functional/p2p_segwit.py
@@ -755,7 +755,7 @@ class SegWitTest(BitcoinTestFramework):
spend_tx.vin[0].scriptSig = CScript([p2wsh_pubkey, b'a'])
spend_tx.rehash()
with self.nodes[0].assert_debug_log(
- expected_msgs=('Not relaying invalid transaction {}'.format(spend_tx.hash), 'was not accepted: mandatory-script-verify-flag-failed (Script evaluated without error but finished with a false/empty top stack element)')):
+ expected_msgs=(spend_tx.hash, 'was not accepted: mandatory-script-verify-flag-failed (Script evaluated without error but finished with a false/empty top stack element)')):
test_transaction_acceptance(self.nodes[0], self.test_node, spend_tx, with_witness=False, accepted=False)
# Now put the witness script in the witness, should succeed after