Merge pull request #4735
3802224
Remove all other print() methods (Wladimir J. van der Laan)9b6d4c5
Move strprintf define to tinyformat.h (Wladimir J. van der Laan)8121258
Remove print() from core functions (Wladimir J. van der Laan)
This commit is contained in:
commit
93ed3d9b4e
15 changed files with 15 additions and 90 deletions
|
@ -80,11 +80,6 @@ std::string CUnsignedAlert::ToString() const
|
||||||
strStatusBar);
|
strStatusBar);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CUnsignedAlert::print() const
|
|
||||||
{
|
|
||||||
LogPrintf("%s", ToString());
|
|
||||||
}
|
|
||||||
|
|
||||||
void CAlert::SetNull()
|
void CAlert::SetNull()
|
||||||
{
|
{
|
||||||
CUnsignedAlert::SetNull();
|
CUnsignedAlert::SetNull();
|
||||||
|
|
|
@ -68,7 +68,6 @@ public:
|
||||||
void SetNull();
|
void SetNull();
|
||||||
|
|
||||||
std::string ToString() const;
|
std::string ToString() const;
|
||||||
void print() const;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/** An alert is a combination of a serialized CUnsignedAlert and a signature. */
|
/** An alert is a combination of a serialized CUnsignedAlert and a signature. */
|
||||||
|
|
40
src/core.cpp
40
src/core.cpp
|
@ -5,18 +5,13 @@
|
||||||
|
|
||||||
#include "core.h"
|
#include "core.h"
|
||||||
|
|
||||||
#include "util.h"
|
#include "tinyformat.h"
|
||||||
|
|
||||||
std::string COutPoint::ToString() const
|
std::string COutPoint::ToString() const
|
||||||
{
|
{
|
||||||
return strprintf("COutPoint(%s, %u)", hash.ToString().substr(0,10), n);
|
return strprintf("COutPoint(%s, %u)", hash.ToString().substr(0,10), n);
|
||||||
}
|
}
|
||||||
|
|
||||||
void COutPoint::print() const
|
|
||||||
{
|
|
||||||
LogPrintf("%s\n", ToString());
|
|
||||||
}
|
|
||||||
|
|
||||||
CTxIn::CTxIn(COutPoint prevoutIn, CScript scriptSigIn, unsigned int nSequenceIn)
|
CTxIn::CTxIn(COutPoint prevoutIn, CScript scriptSigIn, unsigned int nSequenceIn)
|
||||||
{
|
{
|
||||||
prevout = prevoutIn;
|
prevout = prevoutIn;
|
||||||
|
@ -46,11 +41,6 @@ std::string CTxIn::ToString() const
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTxIn::print() const
|
|
||||||
{
|
|
||||||
LogPrintf("%s\n", ToString());
|
|
||||||
}
|
|
||||||
|
|
||||||
CTxOut::CTxOut(int64_t nValueIn, CScript scriptPubKeyIn)
|
CTxOut::CTxOut(int64_t nValueIn, CScript scriptPubKeyIn)
|
||||||
{
|
{
|
||||||
nValue = nValueIn;
|
nValue = nValueIn;
|
||||||
|
@ -67,11 +57,6 @@ std::string CTxOut::ToString() const
|
||||||
return strprintf("CTxOut(nValue=%d.%08d, scriptPubKey=%s)", nValue / COIN, nValue % COIN, scriptPubKey.ToString().substr(0,30));
|
return strprintf("CTxOut(nValue=%d.%08d, scriptPubKey=%s)", nValue / COIN, nValue % COIN, scriptPubKey.ToString().substr(0,30));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTxOut::print() const
|
|
||||||
{
|
|
||||||
LogPrintf("%s\n", ToString());
|
|
||||||
}
|
|
||||||
|
|
||||||
CFeeRate::CFeeRate(int64_t nFeePaid, size_t nSize)
|
CFeeRate::CFeeRate(int64_t nFeePaid, size_t nSize)
|
||||||
{
|
{
|
||||||
if (nSize > 0)
|
if (nSize > 0)
|
||||||
|
@ -92,8 +77,7 @@ int64_t CFeeRate::GetFee(size_t nSize) const
|
||||||
|
|
||||||
std::string CFeeRate::ToString() const
|
std::string CFeeRate::ToString() const
|
||||||
{
|
{
|
||||||
std::string result = FormatMoney(nSatoshisPerK) + " BTC/kB";
|
return strprintf("%d.%08d BTC/kB", nSatoshisPerK / COIN, nSatoshisPerK % COIN);
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CMutableTransaction::CMutableTransaction() : nVersion(CTransaction::CURRENT_VERSION), nLockTime(0) {}
|
CMutableTransaction::CMutableTransaction() : nVersion(CTransaction::CURRENT_VERSION), nLockTime(0) {}
|
||||||
|
@ -171,11 +155,6 @@ std::string CTransaction::ToString() const
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTransaction::print() const
|
|
||||||
{
|
|
||||||
LogPrintf("%s", ToString());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Amount compression:
|
// Amount compression:
|
||||||
// * If the amount is 0, output 0
|
// * If the amount is 0, output 0
|
||||||
// * first, divide the amount (in base units) by the largest power of 10 possible; call the exponent e (e is max 9)
|
// * first, divide the amount (in base units) by the largest power of 10 possible; call the exponent e (e is max 9)
|
||||||
|
@ -285,9 +264,10 @@ uint256 CBlock::CheckMerkleBranch(uint256 hash, const std::vector<uint256>& vMer
|
||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CBlock::print() const
|
std::string CBlock::ToString() const
|
||||||
{
|
{
|
||||||
LogPrintf("CBlock(hash=%s, ver=%d, hashPrevBlock=%s, hashMerkleRoot=%s, nTime=%u, nBits=%08x, nNonce=%u, vtx=%u)\n",
|
std::stringstream s;
|
||||||
|
s << strprintf("CBlock(hash=%s, ver=%d, hashPrevBlock=%s, hashMerkleRoot=%s, nTime=%u, nBits=%08x, nNonce=%u, vtx=%u)\n",
|
||||||
GetHash().ToString(),
|
GetHash().ToString(),
|
||||||
nVersion,
|
nVersion,
|
||||||
hashPrevBlock.ToString(),
|
hashPrevBlock.ToString(),
|
||||||
|
@ -296,11 +276,11 @@ void CBlock::print() const
|
||||||
vtx.size());
|
vtx.size());
|
||||||
for (unsigned int i = 0; i < vtx.size(); i++)
|
for (unsigned int i = 0; i < vtx.size(); i++)
|
||||||
{
|
{
|
||||||
LogPrintf(" ");
|
s << " " << vtx[i].ToString() << "\n";
|
||||||
vtx[i].print();
|
|
||||||
}
|
}
|
||||||
LogPrintf(" vMerkleTree: ");
|
s << " vMerkleTree: ";
|
||||||
for (unsigned int i = 0; i < vMerkleTree.size(); i++)
|
for (unsigned int i = 0; i < vMerkleTree.size(); i++)
|
||||||
LogPrintf("%s ", vMerkleTree[i].ToString());
|
s << " " << vMerkleTree[i].ToString();
|
||||||
LogPrintf("\n");
|
s << "\n";
|
||||||
|
return s.str();
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,6 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ToString() const;
|
std::string ToString() const;
|
||||||
void print() const;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/** An inpoint - a combination of a transaction and an index n into its vin */
|
/** An inpoint - a combination of a transaction and an index n into its vin */
|
||||||
|
@ -107,7 +106,6 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ToString() const;
|
std::string ToString() const;
|
||||||
void print() const;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -200,7 +198,6 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ToString() const;
|
std::string ToString() const;
|
||||||
void print() const;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -279,7 +276,6 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ToString() const;
|
std::string ToString() const;
|
||||||
void print() const;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/** A mutable version of CTransaction. */
|
/** A mutable version of CTransaction. */
|
||||||
|
@ -497,7 +493,7 @@ public:
|
||||||
|
|
||||||
std::vector<uint256> GetMerkleBranch(int nIndex) const;
|
std::vector<uint256> GetMerkleBranch(int nIndex) const;
|
||||||
static uint256 CheckMerkleBranch(uint256 hash, const std::vector<uint256>& vMerkleBranch, int nIndex);
|
static uint256 CheckMerkleBranch(uint256 hash, const std::vector<uint256>& vMerkleBranch, int nIndex);
|
||||||
void print() const;
|
std::string ToString() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1029,8 +1029,7 @@ bool AppInit2(boost::thread_group& threadGroup)
|
||||||
CBlock block;
|
CBlock block;
|
||||||
ReadBlockFromDisk(block, pindex);
|
ReadBlockFromDisk(block, pindex);
|
||||||
block.BuildMerkleTree();
|
block.BuildMerkleTree();
|
||||||
block.print();
|
LogPrintf("%s\n", block.ToString());
|
||||||
LogPrintf("\n");
|
|
||||||
nFound++;
|
nFound++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3968,7 +3968,6 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
||||||
vRecv >> block;
|
vRecv >> block;
|
||||||
|
|
||||||
LogPrint("net", "received block %s peer=%d\n", block.GetHash().ToString(), pfrom->id);
|
LogPrint("net", "received block %s peer=%d\n", block.GetHash().ToString(), pfrom->id);
|
||||||
// block.print();
|
|
||||||
|
|
||||||
CInv inv(MSG_BLOCK, block.GetHash());
|
CInv inv(MSG_BLOCK, block.GetHash());
|
||||||
pfrom->AddInventoryKnown(inv);
|
pfrom->AddInventoryKnown(inv);
|
||||||
|
|
10
src/main.h
10
src/main.h
|
@ -839,11 +839,6 @@ public:
|
||||||
GetBlockHash().ToString());
|
GetBlockHash().ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
void print() const
|
|
||||||
{
|
|
||||||
LogPrintf("%s\n", ToString());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check whether this block index entry is valid up to the passed validity level.
|
// Check whether this block index entry is valid up to the passed validity level.
|
||||||
bool IsValid(enum BlockStatus nUpTo = BLOCK_VALID_TRANSACTIONS) const
|
bool IsValid(enum BlockStatus nUpTo = BLOCK_VALID_TRANSACTIONS) const
|
||||||
{
|
{
|
||||||
|
@ -935,11 +930,6 @@ public:
|
||||||
hashPrev.ToString());
|
hashPrev.ToString());
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
void print() const
|
|
||||||
{
|
|
||||||
LogPrintf("%s\n", ToString());
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Capture information about block/transaction validation */
|
/** Capture information about block/transaction validation */
|
||||||
|
|
|
@ -42,14 +42,6 @@ public:
|
||||||
COrphan(const CTransaction* ptxIn) : ptx(ptxIn), feeRate(0), dPriority(0)
|
COrphan(const CTransaction* ptxIn) : ptx(ptxIn), feeRate(0), dPriority(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void print() const
|
|
||||||
{
|
|
||||||
LogPrintf("COrphan(hash=%s, dPriority=%.1f, fee=%s)\n",
|
|
||||||
ptx->GetHash().ToString(), dPriority, feeRate.ToString());
|
|
||||||
BOOST_FOREACH(uint256 hash, setDependsOn)
|
|
||||||
LogPrintf(" setDependsOn %s\n", hash.ToString());
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
uint64_t nLastBlockTx = 0;
|
uint64_t nLastBlockTx = 0;
|
||||||
|
@ -404,7 +396,7 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey)
|
||||||
|
|
||||||
bool ProcessBlockFound(CBlock* pblock, CWallet& wallet, CReserveKey& reservekey)
|
bool ProcessBlockFound(CBlock* pblock, CWallet& wallet, CReserveKey& reservekey)
|
||||||
{
|
{
|
||||||
pblock->print();
|
LogPrintf("%s\n", pblock->ToString());
|
||||||
LogPrintf("generated %s\n", FormatMoney(pblock->vtx[0].vout[0].nValue));
|
LogPrintf("generated %s\n", FormatMoney(pblock->vtx[0].vout[0].nValue));
|
||||||
|
|
||||||
// Found a solution
|
// Found a solution
|
||||||
|
|
|
@ -874,11 +874,6 @@ uint64_t CNetAddr::GetHash() const
|
||||||
return nRet;
|
return nRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CNetAddr::print() const
|
|
||||||
{
|
|
||||||
LogPrintf("CNetAddr(%s)\n", ToString());
|
|
||||||
}
|
|
||||||
|
|
||||||
// private extensions to enum Network, only returned by GetExtNetwork,
|
// private extensions to enum Network, only returned by GetExtNetwork,
|
||||||
// and only used in GetReachabilityFrom
|
// and only used in GetReachabilityFrom
|
||||||
static const int NET_UNKNOWN = NET_MAX + 0;
|
static const int NET_UNKNOWN = NET_MAX + 0;
|
||||||
|
@ -1107,11 +1102,6 @@ std::string CService::ToString() const
|
||||||
return ToStringIPPort();
|
return ToStringIPPort();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CService::print() const
|
|
||||||
{
|
|
||||||
LogPrintf("CService(%s)\n", ToString());
|
|
||||||
}
|
|
||||||
|
|
||||||
void CService::SetPort(unsigned short portIn)
|
void CService::SetPort(unsigned short portIn)
|
||||||
{
|
{
|
||||||
port = portIn;
|
port = portIn;
|
||||||
|
|
|
@ -80,7 +80,6 @@ class CNetAddr
|
||||||
bool GetInAddr(struct in_addr* pipv4Addr) const;
|
bool GetInAddr(struct in_addr* pipv4Addr) const;
|
||||||
std::vector<unsigned char> GetGroup() const;
|
std::vector<unsigned char> GetGroup() const;
|
||||||
int GetReachabilityFrom(const CNetAddr *paddrPartner = NULL) const;
|
int GetReachabilityFrom(const CNetAddr *paddrPartner = NULL) const;
|
||||||
void print() const;
|
|
||||||
|
|
||||||
CNetAddr(const struct in6_addr& pipv6Addr);
|
CNetAddr(const struct in6_addr& pipv6Addr);
|
||||||
bool GetIn6Addr(struct in6_addr* pipv6Addr) const;
|
bool GetIn6Addr(struct in6_addr* pipv6Addr) const;
|
||||||
|
@ -145,7 +144,6 @@ class CService : public CNetAddr
|
||||||
std::string ToString() const;
|
std::string ToString() const;
|
||||||
std::string ToStringPort() const;
|
std::string ToStringPort() const;
|
||||||
std::string ToStringIPPort() const;
|
std::string ToStringIPPort() const;
|
||||||
void print() const;
|
|
||||||
|
|
||||||
CService(const struct in6_addr& ipv6Addr, unsigned short port);
|
CService(const struct in6_addr& ipv6Addr, unsigned short port);
|
||||||
CService(const struct sockaddr_in6& addr);
|
CService(const struct sockaddr_in6& addr);
|
||||||
|
|
|
@ -144,9 +144,3 @@ std::string CInv::ToString() const
|
||||||
{
|
{
|
||||||
return strprintf("%s %s", GetCommand(), hash.ToString());
|
return strprintf("%s %s", GetCommand(), hash.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CInv::print() const
|
|
||||||
{
|
|
||||||
LogPrintf("CInv(%s)\n", ToString());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -98,8 +98,6 @@ class CAddress : public CService
|
||||||
READWRITE(*pip);
|
READWRITE(*pip);
|
||||||
)
|
)
|
||||||
|
|
||||||
void print() const;
|
|
||||||
|
|
||||||
// TODO: make private (improves encapsulation)
|
// TODO: make private (improves encapsulation)
|
||||||
public:
|
public:
|
||||||
uint64_t nServices;
|
uint64_t nServices;
|
||||||
|
@ -130,7 +128,6 @@ class CInv
|
||||||
bool IsKnownType() const;
|
bool IsKnownType() const;
|
||||||
const char* GetCommand() const;
|
const char* GetCommand() const;
|
||||||
std::string ToString() const;
|
std::string ToString() const;
|
||||||
void print() const;
|
|
||||||
|
|
||||||
// TODO: make private (improves encapsulation)
|
// TODO: make private (improves encapsulation)
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -1007,4 +1007,6 @@ TINYFORMAT_WRAP_FORMAT_N(16, returnType, funcName, funcDeclSuffix, bodyPrefix, s
|
||||||
|
|
||||||
} // namespace tinyformat
|
} // namespace tinyformat
|
||||||
|
|
||||||
|
#define strprintf tfm::format
|
||||||
|
|
||||||
#endif // TINYFORMAT_H_INCLUDED
|
#endif // TINYFORMAT_H_INCLUDED
|
||||||
|
|
|
@ -108,7 +108,6 @@ bool LogAcceptCategory(const char* category);
|
||||||
/* Send a string to the log output */
|
/* Send a string to the log output */
|
||||||
int LogPrintStr(const std::string &str);
|
int LogPrintStr(const std::string &str);
|
||||||
|
|
||||||
#define strprintf tfm::format
|
|
||||||
#define LogPrintf(...) LogPrint(NULL, __VA_ARGS__)
|
#define LogPrintf(...) LogPrint(NULL, __VA_ARGS__)
|
||||||
|
|
||||||
/* When we switch to C++11, this can be switched to variadic templates instead
|
/* When we switch to C++11, this can be switched to variadic templates instead
|
||||||
|
|
|
@ -824,11 +824,6 @@ public:
|
||||||
{
|
{
|
||||||
return strprintf("COutput(%s, %d, %d) [%s]", tx->GetHash().ToString(), i, nDepth, FormatMoney(tx->vout[i].nValue).c_str());
|
return strprintf("COutput(%s, %d, %d) [%s]", tx->GetHash().ToString(), i, nDepth, FormatMoney(tx->vout[i].nValue).c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void print() const
|
|
||||||
{
|
|
||||||
LogPrintf("%s\n", ToString());
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue