By dropping the chain argument to GetDifficulty. GetDifficulty was called in two ways:
- with a guaranteed non-null blockindex
- with no argument
Change the latter case to be provided chainActive.Tip() explicitly.
Introduced in: #11748
This removes the need to include rpc/blockchain.cpp in order to put
GetDifficulty under test. GetDifficulty was called in two ways:
* with a guaranteed non-null blockindex
* with no argument
Change the latter case to be provided chainActive.Tip() explicitly.
Dropped the now-unused chain.h include as well.
Concept ACK
What about adding this to lint-includes.sh?
diff --git a/contrib/devtools/lint-includes.sh b/contrib/devtools/lint-includes.sh
index 0f9fec4..97b037f 100755
--- a/contrib/devtools/lint-includes.sh
+++ b/contrib/devtools/lint-includes.sh
@@ -40,4 +40,12 @@ if [[ ${QUOTE_SYNTAX_INCLUDES} != "" ]]; then
EXIT_CODE=1
fi
+INCLUDED_CPP_FILES=$(git grep -E "^#include <[^>]*\.cpp>" -- "**/*.cpp" "**/*.h")
+if [[ ${INCLUDED_CPP_FILES} != "" ]]; then
+ echo "The following files #include .cpp files:"
+ echo "${INCLUDED_CPP_FILES}"
+ echo
+ EXIT_CODE=1
+fi
+
exit ${EXIT_CODE}
@practicalswift I'm in favor - we'd need to merge this and #13291 to get something like that to pass, so how about as a follow-up?
341 | @@ -352,7 +342,7 @@ static UniValue getdifficulty(const JSONRPCRequest& request) 342 | ); 343 | 344 | LOCK(cs_main); 345 | - return GetDifficulty(); 346 | + return GetDifficulty(chainActive.Tip());
style nit: Personally I prefer ::chainActive for globals.
I like this too but I'm going to leave this PR be. I have a follow-up I think will accommodate it better.
utACK ebec7317ca1acbc65afa7fb08fc219c315fc4527
utACK ebec7317ca1acbc65afa7fb08fc219c315fc4527
utACK ebec7317ca1acbc65afa7fb08fc219c315fc4527
utACK ebec7317ca1acbc65afa7fb08fc219c315fc4527