Skip to content

Commit

Permalink
Merge #13163: Make it clear which functions that are intended to be t…
Browse files Browse the repository at this point in the history
…ranslation unit local (wallet files)

Summary:
c3f34d0 Make it clear which functions that are intended to be translation unit local (practicalswift)

Pull request description:

  Make it clear which functions that are intended to be translation unit local.

  Do not share functions that are meant to be translation unit local with other translation units. Use internal linkage for those consistently.

Tree-SHA512: 05eebd233d5cfbf6116724eec3a99b465bf534ca220f2b6f5e56341a7da41387454d3cb6ceadd8ab6714a5df94069e4ad0dcab8801ccc7e8949be7199a19fb53

Partial Backport of Core PR13163 (wallet/rpcdump.cpp, wallet/rpcwallet.cpp, and wallet/walletdb.cpp)
bitcoin/bitcoin#13163

Part of breaking up of D3293.

Test Plan:
  make check

Reviewers: O1 Bitcoin ABC, #bitcoin_abc, jasonbcox, deadalnix, Fabien

Reviewed By: O1 Bitcoin ABC, #bitcoin_abc, deadalnix

Differential Revision: https://reviews.bitcoinabc.org/D3510
  • Loading branch information
Nico Guiton committed Jul 2, 2019
1 parent d671f78 commit e8149e5
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 31 deletions.
20 changes: 10 additions & 10 deletions src/wallet/rpcdump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ static std::string EncodeDumpString(const std::string &str) {
return ret.str();
}

std::string DecodeDumpString(const std::string &str) {
static std::string DecodeDumpString(const std::string &str) {
std::stringstream ret;
for (unsigned int pos = 0; pos < str.length(); pos++) {
uint8_t c = str[pos];
Expand Down Expand Up @@ -207,10 +207,10 @@ UniValue abortrescan(const Config &config, const JSONRPCRequest &request) {
return true;
}

void ImportAddress(CWallet *, const CTxDestination &dest,
const std::string &strLabel);
void ImportScript(CWallet *const pwallet, const CScript &script,
const std::string &strLabel, bool isRedeemScript) {
static void ImportAddress(CWallet *, const CTxDestination &dest,
const std::string &strLabel);
static void ImportScript(CWallet *const pwallet, const CScript &script,
const std::string &strLabel, bool isRedeemScript) {
if (!isRedeemScript && ::IsMine(*pwallet, script) == ISMINE_SPENDABLE) {
throw JSONRPCError(RPC_WALLET_ERROR, "The wallet already contains the "
"private key for this address or "
Expand Down Expand Up @@ -238,8 +238,8 @@ void ImportScript(CWallet *const pwallet, const CScript &script,
}
}

void ImportAddress(CWallet *const pwallet, const CTxDestination &dest,
const std::string &strLabel) {
static void ImportAddress(CWallet *const pwallet, const CTxDestination &dest,
const std::string &strLabel) {
CScript script = GetScriptForDestination(dest);
ImportScript(pwallet, script, strLabel, false);
// add to address book or update label
Expand Down Expand Up @@ -911,8 +911,8 @@ UniValue dumpwallet(const Config &config, const JSONRPCRequest &request) {
return reply;
}

UniValue ProcessImport(CWallet *const pwallet, const UniValue &data,
const int64_t timestamp) {
static UniValue ProcessImport(CWallet *const pwallet, const UniValue &data,
const int64_t timestamp) {
try {
bool success = false;

Expand Down Expand Up @@ -1280,7 +1280,7 @@ UniValue ProcessImport(CWallet *const pwallet, const UniValue &data,
}
}

int64_t GetImportTimestamp(const UniValue &data, int64_t now) {
static int64_t GetImportTimestamp(const UniValue &data, int64_t now) {
if (data.exists("timestamp")) {
const UniValue &timestamp = data["timestamp"];
if (timestamp.isNum()) {
Expand Down
39 changes: 21 additions & 18 deletions src/wallet/rpcwallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ void EnsureWalletIsUnlocked(CWallet *const pwallet) {
}
}

void WalletTxToJSON(const CWalletTx &wtx, UniValue &entry) {
static void WalletTxToJSON(const CWalletTx &wtx, UniValue &entry) {
int confirms = wtx.GetDepthInMainChain();
entry.pushKV("confirmations", confirms);
if (wtx.IsCoinBase()) {
Expand Down Expand Up @@ -138,7 +138,7 @@ void WalletTxToJSON(const CWalletTx &wtx, UniValue &entry) {
}
}

std::string LabelFromValue(const UniValue &value) {
static std::string LabelFromValue(const UniValue &value) {
std::string label = value.get_str();
if (label == "*") {
throw JSONRPCError(RPC_WALLET_INVALID_LABEL_NAME, "Invalid label name");
Expand Down Expand Up @@ -223,7 +223,8 @@ CTxDestination GetLabelDestination(CWallet *const pwallet,
return dest;
}

UniValue getlabeladdress(const Config &config, const JSONRPCRequest &request) {
static UniValue getlabeladdress(const Config &config,
const JSONRPCRequest &request) {
CWallet *const pwallet = GetWalletForJSONRPCRequest(request);
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
return NullUniValue;
Expand Down Expand Up @@ -311,7 +312,7 @@ static UniValue getrawchangeaddress(const Config &config,
return EncodeDestination(dest);
}

UniValue setlabel(const Config &config, const JSONRPCRequest &request) {
static UniValue setlabel(const Config &config, const JSONRPCRequest &request) {
CWallet *const pwallet = GetWalletForJSONRPCRequest(request);
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
return NullUniValue;
Expand Down Expand Up @@ -823,8 +824,8 @@ static UniValue getreceivedbyaddress(const Config &config,
return ValueFromAmount(nAmount);
}

UniValue getreceivedbylabel(const Config &config,
const JSONRPCRequest &request) {
static UniValue getreceivedbylabel(const Config &config,
const JSONRPCRequest &request) {
CWallet *const pwallet = GetWalletForJSONRPCRequest(request);
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
return NullUniValue;
Expand Down Expand Up @@ -1368,8 +1369,8 @@ static UniValue sendmany(const Config &config, const JSONRPCRequest &request) {
return tx->GetId().GetHex();
}

UniValue addmultisigaddress(const Config &config,
const JSONRPCRequest &request) {
static UniValue addmultisigaddress(const Config &config,
const JSONRPCRequest &request) {
CWallet *const pwallet = GetWalletForJSONRPCRequest(request);
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
return NullUniValue;
Expand Down Expand Up @@ -1481,8 +1482,8 @@ struct tallyitem {
}
};

UniValue ListReceived(const Config &config, CWallet *const pwallet,
const UniValue &params, bool by_label) {
static UniValue ListReceived(const Config &config, CWallet *const pwallet,
const UniValue &params, bool by_label) {
// Minimum confirmations
int nMinDepth = 1;
if (!params[0].isNull()) {
Expand Down Expand Up @@ -1699,8 +1700,8 @@ static UniValue listreceivedbyaddress(const Config &config,
return ListReceived(config, pwallet, request.params, false);
}

UniValue listreceivedbylabel(const Config &config,
const JSONRPCRequest &request) {
static UniValue listreceivedbylabel(const Config &config,
const JSONRPCRequest &request) {
CWallet *const pwallet = GetWalletForJSONRPCRequest(request);
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
return NullUniValue;
Expand Down Expand Up @@ -1767,9 +1768,10 @@ static void MaybePushAddress(UniValue &entry, const CTxDestination &dest) {
* @param ret The UniValue into which the result is stored.
* @param filter The "is mine" filter bool.
*/
void ListTransactions(CWallet *const pwallet, const CWalletTx &wtx,
const std::string &strAccount, int nMinDepth, bool fLong,
UniValue &ret, const isminefilter &filter) {
static void ListTransactions(CWallet *const pwallet, const CWalletTx &wtx,
const std::string &strAccount, int nMinDepth,
bool fLong, UniValue &ret,
const isminefilter &filter) {
Amount nFee;
std::string strSentAccount;
std::list<COutputEntry> listReceived;
Expand Down Expand Up @@ -1847,8 +1849,8 @@ void ListTransactions(CWallet *const pwallet, const CWalletTx &wtx,
}
}

void AcentryToJSON(const CAccountingEntry &acentry,
const std::string &strAccount, UniValue &ret) {
static void AcentryToJSON(const CAccountingEntry &acentry,
const std::string &strAccount, UniValue &ret) {
bool fAllAccounts = (strAccount == std::string("*"));

if (fAllAccounts || acentry.strAccount == strAccount) {
Expand Down Expand Up @@ -4105,7 +4107,8 @@ class DescribeWalletAddressVisitor : public boost::static_visitor<UniValue> {
}
};

UniValue DescribeWalletAddress(CWallet *pwallet, const CTxDestination &dest) {
static UniValue DescribeWalletAddress(CWallet *pwallet,
const CTxDestination &dest) {
UniValue ret(UniValue::VOBJ);
UniValue detail = DescribeAddress(dest);
ret.pushKVs(detail);
Expand Down
6 changes: 3 additions & 3 deletions src/wallet/walletdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,9 +266,9 @@ class CWalletScanState {
}
};

bool ReadKeyValue(CWallet *pwallet, CDataStream &ssKey, CDataStream &ssValue,
CWalletScanState &wss, std::string &strType,
std::string &strErr) {
static bool ReadKeyValue(CWallet *pwallet, CDataStream &ssKey,
CDataStream &ssValue, CWalletScanState &wss,
std::string &strType, std::string &strErr) {
try {
// Unserialize
// Taking advantage of the fact that pair serialization is just the two
Expand Down

0 comments on commit e8149e5

Please sign in to comment.