-
Notifications
You must be signed in to change notification settings - Fork 37.7k
Remove unused C++ code not covered by unit tests #10075
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
src/rpc/protocol.cpp
Outdated
@@ -114,13 +114,3 @@ bool GetAuthCookie(std::string *cookie_out) | |||
*cookie_out = cookie; | |||
return true; | |||
} | |||
|
|||
void DeleteAuthCookie() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh, it's a mistake that this is unused; the auth cookie is supposed to be removed on shutdown.
Apparently I mistakenly removed the call from StopRPC
in #5677/40b556d3742a1f65d67e2d4c760d0b13fe8be5b7. Good catch :)
src/wallet/wallet.cpp
Outdated
@@ -3495,22 +3495,6 @@ bool CWallet::LoadDestData(const CTxDestination &dest, const std::string &key, c | |||
return true; | |||
} | |||
|
|||
bool CWallet::GetDestData(const CTxDestination &dest, const std::string &key, std::string *value) const |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is part of the *DestData
API, please don't remove it just because it's not used at the moment. Same reasoning as here: #9987 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@laanwj Thanks for reviewing. I see - so basically a test is needed here :-)
src/net.cpp
Outdated
@@ -2616,7 +2598,6 @@ int CConnman::GetBestHeight() const | |||
} | |||
|
|||
unsigned int CConnman::GetReceiveFloodSize() const { return nReceiveFloodSize; } | |||
unsigned int CConnman::GetSendBufferSize() const{ return nSendBufferMaxSize; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CConnman is recent code and part of an ongoing effort by @theuni, please discuss with him before removing things.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@practicalswift Yes, thanks, that's a good idea.
Trivia: This PR combined with #9987 removes 0.134 % (173 of 128 675 lines of code) of the Bitcoin C++ codebase :-)
|
@@ -103,8 +103,3 @@ std::string ChainNameFromCommandLine() | |||
return CBaseChainParams::TESTNET; | |||
return CBaseChainParams::MAIN; | |||
} | |||
|
|||
bool AreBaseParamsConfigured() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK on this one, apparently the last use of this went away in #6149/27d760580456d206c5a02ef29797f296f510099c.
@@ -131,14 +131,6 @@ void CKey::MakeNewKey(bool fCompressedIn) { | |||
fCompressed = fCompressedIn; | |||
} | |||
|
|||
bool CKey::SetPrivKey(const CPrivKey &privkey, bool fCompressedIn) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK on this one. This seems to have been unused since #5227/36fa4a78acac0ae6bb0e95c6ef78630120a28bdd.
@@ -179,12 +179,6 @@ bool CNetAddr::IsLocal() const | |||
return false; | |||
} | |||
|
|||
bool CNetAddr::IsMulticast() const |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK on this one. Cannot find when this was ever used, and I don't think we need this now or on the forseeable future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like it was introduced in #735 (5 years ago) and yes possibly never used.
src/netaddress.cpp
Outdated
@@ -570,11 +564,6 @@ std::string CService::ToString() const | |||
return ToStringIPPort(); | |||
} | |||
|
|||
void CService::SetPort(unsigned short portIn) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Setting ports seems to be reasonably useful part of the API, unless all of CService is made immutable I'd suggest keeping this.
@@ -463,15 +463,6 @@ void CDBEnv::CloseDb(const std::string& strFile) | |||
} | |||
} | |||
|
|||
bool CDBEnv::RemoveDb(const std::string& strFile) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not 100% sure about this one. We don't use it, and haven't used it for a long time. From what I see it was introduced in eed1785 (pull# unknown) and never used. Would deleting wallets be something we'd ever support? (e.g. as part of multiwallet). It is an extremely dangerous thing to do, on the other hand for watch-only wallets it'd be useful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
9f4d9b4
to
1f8e7dc
Compare
@laanwj I've now addressed your review items. Please let me know if any further adjustments are needed :-) |
src/rpc/server.cpp
Outdated
@@ -322,6 +322,7 @@ void StopRPC() | |||
{ | |||
LogPrint("rpc", "Stopping RPC\n"); | |||
deadlineTimers.clear(); | |||
DeleteAuthCookie(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this could/should be broken out into it's own PR. It's wasn't obvious right away why this was being added.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At least it's a separate commit in this PR. But splitting it to a separate PR would make sense, yes.
Let me know if there are any suggestions on further tweaks needed for this PR :-) |
This needs a rebase. |
@fanquake Thanks for the notification. Now rebased! Let me know if anything needs to be changed in this PR. |
ACK b51aaf1 |
b51aaf1 Remove unused C++ code not covered by unit tests (practicalswift) Tree-SHA512: 267bbd87df01a296bf23e82a8b6ee968e13e23a6aaecc535d803890a3e3e9f6208c7fc4c1f97afd98ed3e498b12fe1ada7e3cb2977ad12359a813f57336c74e5
b51aaf1 Remove unused C++ code not covered by unit tests (practicalswift) Tree-SHA512: 267bbd87df01a296bf23e82a8b6ee968e13e23a6aaecc535d803890a3e3e9f6208c7fc4c1f97afd98ed3e498b12fe1ada7e3cb2977ad12359a813f57336c74e5
b51aaf1 Remove unused C++ code not covered by unit tests (practicalswift) Tree-SHA512: 267bbd87df01a296bf23e82a8b6ee968e13e23a6aaecc535d803890a3e3e9f6208c7fc4c1f97afd98ed3e498b12fe1ada7e3cb2977ad12359a813f57336c74e5
b51aaf1 Remove unused C++ code not covered by unit tests (practicalswift) Tree-SHA512: 267bbd87df01a296bf23e82a8b6ee968e13e23a6aaecc535d803890a3e3e9f6208c7fc4c1f97afd98ed3e498b12fe1ada7e3cb2977ad12359a813f57336c74e5
b51aaf1 Remove unused C++ code not covered by unit tests (practicalswift) Tree-SHA512: 267bbd87df01a296bf23e82a8b6ee968e13e23a6aaecc535d803890a3e3e9f6208c7fc4c1f97afd98ed3e498b12fe1ada7e3cb2977ad12359a813f57336c74e5
b51aaf1 Remove unused C++ code not covered by unit tests (practicalswift) Tree-SHA512: 267bbd87df01a296bf23e82a8b6ee968e13e23a6aaecc535d803890a3e3e9f6208c7fc4c1f97afd98ed3e498b12fe1ada7e3cb2977ad12359a813f57336c74e5
b51aaf1 Remove unused C++ code not covered by unit tests (practicalswift) Tree-SHA512: 267bbd87df01a296bf23e82a8b6ee968e13e23a6aaecc535d803890a3e3e9f6208c7fc4c1f97afd98ed3e498b12fe1ada7e3cb2977ad12359a813f57336c74e5
b51aaf1 Remove unused C++ code not covered by unit tests (practicalswift) Tree-SHA512: 267bbd87df01a296bf23e82a8b6ee968e13e23a6aaecc535d803890a3e3e9f6208c7fc4c1f97afd98ed3e498b12fe1ada7e3cb2977ad12359a813f57336c74e5
b51aaf1 Remove unused C++ code not covered by unit tests (practicalswift) Tree-SHA512: 267bbd87df01a296bf23e82a8b6ee968e13e23a6aaecc535d803890a3e3e9f6208c7fc4c1f97afd98ed3e498b12fe1ada7e3cb2977ad12359a813f57336c74e5
b51aaf1 Remove unused C++ code not covered by unit tests (practicalswift) Tree-SHA512: 267bbd87df01a296bf23e82a8b6ee968e13e23a6aaecc535d803890a3e3e9f6208c7fc4c1f97afd98ed3e498b12fe1ada7e3cb2977ad12359a813f57336c74e5
b51aaf1 Remove unused C++ code not covered by unit tests (practicalswift) Tree-SHA512: 267bbd87df01a296bf23e82a8b6ee968e13e23a6aaecc535d803890a3e3e9f6208c7fc4c1f97afd98ed3e498b12fe1ada7e3cb2977ad12359a813f57336c74e5
b51aaf1 Remove unused C++ code not covered by unit tests (practicalswift) Tree-SHA512: 267bbd87df01a296bf23e82a8b6ee968e13e23a6aaecc535d803890a3e3e9f6208c7fc4c1f97afd98ed3e498b12fe1ada7e3cb2977ad12359a813f57336c74e5
d5526bd Wrap dumpwallet warning and note scripts aren't dumped (MeshCollider) 3711c6a Add wallet backup text to import*, add* and dumpwallet RPCs (MeshCollider) dbda874 [Wallet] always show help-line of wallet encryption calls (Jonas Schnelli) 20c269b Avoid opening copied wallet databases simultaneously (Russell Yanofsky) e411b70 [wallet] Fix leak in CDB constructor (João Barbosa) f15aeea Change getmininginfo errors field to warnings (Andrew Chow) c04390b Unify help text for GetWarnings output in get*info RPCs (random-zebra) 1d966ce Add warnings field to getblockchaininfo (Andrew Chow) ffcd781 [Trivial] Cleanup after MOVE-ONLY commits (random-zebra) e067235 MOVEONLY: Init functions wallet/wallet.cpp -> wallet/init.cpp (random-zebra) e947eec MOVEONLY: Fee functions wallet/wallet.cpp -> wallet/fees.cpp (random-zebra) 2188c3e Move some static functions out of wallet.h/cpp (random-zebra) f49acf7 [wallet] [moveonly] Move CAffectedKeysVisitor (random-zebra) 8bd979f [wallet] Specify wallet name in wallet loading errors (random-zebra) 900bbfa Reject invalid wallet files (João Barbosa) a1f4e2a Reject duplicate wallet filenames (random-zebra) ee52c2e Fix misleading "Method not found" multiwallet errors (Russell Yanofsky) ce35e1e [Qt] Use wallet 0 in rpc console if running with multiple wallets (random-zebra) 37089d1 [tests] Update wallet_multiwallet.py functional test (random-zebra) 3955ee9 [Doc] Update release notes (random-zebra) 4fd5913 [wallet] [rpc] Add listwallets RPC (John Newbery) 1525281 [wallet] [rpc] print wallet name in getwalletinfo (John Newbery) fdf5da0 [wallet] fix comment for CWallet::Verify() (John Newbery) cf4a90b Remove factor of 3 from definition of dust. (random-zebra) a1c56fd [Policy] Introduce -dustrelayfee (random-zebra) 9fb29cc [Doc] Update multiwallet release notes (random-zebra) 379255e [Tests][Trivial] Add wallet_multiwallet.py to test_runner (random-zebra) 808fbc3 [Bugfix] consider boolean value of -zapwallettxes ParameterInteraction (random-zebra) f9141f8 [QA] Add wallet_multiwallet.py functional test (John Newbery) 2e02006 Rename -usewallet to -rpcwallet (Alex Morcos) a64440b Select wallet based on the given endpoint (Jonas Schnelli) 5683a9c Complete previous commit by moving mn stuff out of libbitcoin_wallet (random-zebra) b0fe92f Fix test_pivx circular dependency issue (random-zebra) 6cb2b92 Add wallet endpoint support to bitcoin-cli (-usewallet) (Jonas Schnelli) 7dd3916 Register wallet endpoint (Jonas Schnelli) 5bd1bd7 Properly forbid -salvagewallet and -zapwallettxes for multi wallet. (Alex Morcos) 41a7335 Remove unused variables (practicalswift) 5c3d73f Avoid CWalletTx copies in GetAddressBalances and GetAddressGroupings (Russell Yanofsky) e7cafab [Refactoring] Mimic ListCoins for sapling notes (random-zebra) 54fa122 [qt] Move some WalletModel functions into CWallet (random-zebra) 494ba64 [test] Add test for getmemoryinfo (random-zebra) 2394083 [Wallet] unset change position when there is no change on exact match (Gregory Sanders) 7d977ac Remove unused C++ code not covered by unit tests (random-zebra) 60bb4da ApproximateBestSubset should take inputs by reference, not value (Ryan Havar) 3633d75 Initialize nRelockTime (Patrick Strateman) 3a599d0 [Refactor] Return safeTx boolean in CheckTXAvailability (random-zebra) f219be9 Add safe flag to listunspent result (NicolasDorier) 0201065 Add COutput::fSafe member for safe handling of unconfirmed outputs (random-zebra) 75c8c6d Disallow copy of CReserveKeys (Gregory Sanders) 8378322 [Refactor] Replace optional reserveKey in PBF with unique pointer (random-zebra) Pull request description: I think these are all the remaining Bitcoin Core v0.15 PRs in the wallet area that we don't have yet, and are useful to us. I've grouped them here since they are all pretty small, simple, and narrow-focused (on the wallet/rpcwallet files). This changeset is based on top of - [x] #2337 as it keeps going with the multiwallet implementation, adding: - RPC endpoint support - `listwallets` RPC - wallet name in `getwalletinfo` RPC - `wallet_multiwallet.py` functional test As in some areas we are much closer to upstream, some of the commits needed adaptations (especially the functional tests). A couple of commits have been extended to include shield-related code. List of upstream PRs backported/adapted: - bitcoin#9906 : Disallow copy constructor CReserveKeys - bitcoin#9830 : Add safe flag to listunspent result - bitcoin#9993 : Initialize nRelockTime - bitcoin#10108 : ApproximateBestSubset should take inputs by reference, not value - bitcoin#10075 : Remove unused C++ code not covered by unit tests - bitcoin#10257 : Add test for getmemoryinfo - bitcoin#10295 : Move some WalletModel functions into CWallet - bitcoin#10500 : Avoid CWalletTx copies in GetAddressBalances and GetAddressGroupings - bitcoin#10522 : Remove unused variables - bitcoin#10816 : Properly forbid -salvagewallet and -zapwallettxes for multi wallet - bitcoin#10849 : Multiwallet: simplest endpoint support - bitcoin#9380 : Separate different uses of minimum fees (only dustRelayFee) - bitcoin#10817 : Redefine Dust and add a discard_rate (only first commit) - bitcoin#10883 : Rename -usewallet to -rpcwallet - bitcoin#10604 : Add listwallets RPC, include wallet name in getwalletinfo + tests - bitcoin#10893 : Avoid running multiwallet.py twice - bitcoin#10870 : Use wallet 0 in rpc console if running with multiple wallets - bitcoin#10931 : Fix misleading "method not found" multiwallet errors - bitcoin#10885 : Reject invalid wallets - bitcoin#11022 : Basic keypool topup - bitcoin#10976 : [MOVEONLY] Move some static functions out of wallet.h/cpp - bitcoin#11310 : Test listwallets RPC - bitcoin#10858 : "errors" to getblockchaininfo + unify "errors" field in get*info RPCs - bitcoin#11492 : Fix leak in CDB constructor - bitcoin#11476 : Avoid opening copied wallet databases simultaneously - bitcoin#11590 : always show help-line of wallet encryption calls - bitcoin#11289 : Add wallet backup text to import* and add* RPCs ACKs for top commit: furszy: re-re-utACK d5526bd. Fuzzbawls: ACK d5526bd Tree-SHA512: 115c4916ee212539b0a1b2cb25783ddf6753f5376de739a084191e874ed8717fff2c7cd9d744e397891f14eaa459ef2f48d675168621ef7316e81758fa6559f2
223bda1 key.cpp: Use PubKey constant size. (furszy) 0c6f95d remove unused code (furszy) Pull request description: Straightforward unused code cleanup coming from bitcoin#9987 and bitcoin#10075. ACKs for top commit: random-zebra: utACK 223bda1 Fuzzbawls: ACK 223bda1 Tree-SHA512: 9937edbcf4f59ba7835f889ea4638d9bd32e28e3cd865ed043a1f0856ab8ec2b08a3cd4f851536db1703b7f21d4910f22fb905231f73dd0ae7adecd6f5a07055
No description provided.