![]() |
Master Core
v0.0.9 - 2abfd2849db8ba7a83957c64eb976b406713c123
|
#include "compat.h"
#include "serialize.h"
#include "tinyformat.h"
#include <cstdio>
#include <exception>
#include <map>
#include <stdarg.h>
#include <stdint.h>
#include <string>
#include <utility>
#include <vector>
#include <sys/resource.h>
#include <sys/time.h>
#include <sys/types.h>
#include <boost/filesystem/path.hpp>
#include <boost/thread.hpp>
Go to the source code of this file.
Classes | |
class | CMedianFilter< T > |
Median filter over a stream of values. More... | |
Macros | |
#define | BEGIN(a) ((char*)&(a)) |
#define | END(a) ((char*)&((&(a))[1])) |
#define | UBEGIN(a) ((unsigned char*)&(a)) |
#define | UEND(a) ((unsigned char*)&((&(a))[1])) |
#define | ARRAYLEN(array) (sizeof(array)/sizeof((array)[0])) |
#define | PAIRTYPE(t1, t2) std::pair<t1, t2> |
#define | MAX_PATH 1024 |
#define | MSG_NOSIGNAL 0 |
#define | strprintf tfm::format |
#define | LogPrintf(...) LogPrint(NULL, __VA_ARGS__) |
#define | MAKE_ERROR_AND_LOG_FUNC(n) |
#define | PRIO_MAX 20 |
#define | THREAD_PRIORITY_LOWEST PRIO_MAX |
#define | THREAD_PRIORITY_BELOW_NORMAL 2 |
#define | THREAD_PRIORITY_NORMAL 0 |
#define | THREAD_PRIORITY_ABOVE_NORMAL (-2) |
Functions | |
template<size_t nBytes, typename T > | |
T * | alignup (T *p) |
void | MilliSleep (int64_t n) |
void | RandAddSeed () |
void | RandAddSeedPerfmon () |
void | SetupEnvironment () |
bool | LogAcceptCategory (const char *category) |
int | LogPrintStr (const std::string &str) |
static int | LogPrint (const char *category, const char *format) |
static bool | error (const char *format) |
void | LogException (std::exception *pex, const char *pszThread) |
void | PrintExceptionContinue (std::exception *pex, const char *pszThread) |
std::string | FormatMoney (int64_t n, bool fPlus=false) |
bool | ParseMoney (const std::string &str, int64_t &nRet) |
bool | ParseMoney (const char *pszIn, int64_t &nRet) |
std::string | SanitizeString (const std::string &str) |
std::vector< unsigned char > | ParseHex (const char *psz) |
std::vector< unsigned char > | ParseHex (const std::string &str) |
bool | IsHex (const std::string &str) |
std::vector< unsigned char > | DecodeBase64 (const char *p, bool *pfInvalid=NULL) |
std::string | DecodeBase64 (const std::string &str) |
std::string | EncodeBase64 (const unsigned char *pch, size_t len) |
std::string | EncodeBase64 (const std::string &str) |
std::vector< unsigned char > | DecodeBase32 (const char *p, bool *pfInvalid=NULL) |
std::string | DecodeBase32 (const std::string &str) |
std::string | EncodeBase32 (const unsigned char *pch, size_t len) |
std::string | EncodeBase32 (const std::string &str) |
void | ParseParameters (int argc, const char *const argv[]) |
bool | WildcardMatch (const char *psz, const char *mask) |
bool | WildcardMatch (const std::string &str, const std::string &mask) |
void | FileCommit (FILE *fileout) |
bool | TruncateFile (FILE *file, unsigned int length) |
int | RaiseFileDescriptorLimit (int nMinFD) |
void | AllocateFileRange (FILE *file, unsigned int offset, unsigned int length) |
bool | RenameOver (boost::filesystem::path src, boost::filesystem::path dest) |
bool | TryCreateDirectory (const boost::filesystem::path &p) |
boost::filesystem::path | GetDefaultDataDir () |
const boost::filesystem::path & | GetDataDir (bool fNetSpecific=true) |
boost::filesystem::path | GetConfigFile () |
boost::filesystem::path | GetPidFile () |
void | CreatePidFile (const boost::filesystem::path &path, pid_t pid) |
void | ReadConfigFile (std::map< std::string, std::string > &mapSettingsRet, std::map< std::string, std::vector< std::string > > &mapMultiSettingsRet) |
boost::filesystem::path | GetTempPath () |
void | ShrinkDebugFile () |
int | GetRandInt (int nMax) |
uint64_t | GetRand (uint64_t nMax) |
uint256 | GetRandHash () |
int64_t | GetTime () |
void | SetMockTime (int64_t nMockTimeIn) |
int64_t | GetAdjustedTime () |
int64_t | GetTimeOffset () |
std::string | FormatFullVersion () |
std::string | FormatSubVersion (const std::string &name, int nClientVersion, const std::vector< std::string > &comments) |
void | AddTimeData (const CNetAddr &ip, int64_t nTime) |
void | runCommand (std::string strCommand) |
std::string | i64tostr (int64_t n) |
std::string | itostr (int n) |
int64_t | atoi64 (const char *psz) |
int64_t | atoi64 (const std::string &str) |
int | atoi (const std::string &str) |
int | roundint (double d) |
int64_t | roundint64 (double d) |
int64_t | abs64 (int64_t n) |
template<typename T > | |
std::string | HexStr (const T itbegin, const T itend, bool fSpaces=false) |
template<typename T > | |
std::string | HexStr (const T &vch, bool fSpaces=false) |
template<typename T > | |
void | PrintHex (const T pbegin, const T pend, const char *pszFormat="%s", bool fSpaces=true) |
void | PrintHex (const std::vector< unsigned char > &vch, const char *pszFormat="%s", bool fSpaces=true) |
int64_t | GetPerformanceCounter () |
int64_t | GetTimeMillis () |
int64_t | GetTimeMicros () |
std::string | DateTimeStrFormat (const char *pszFormat, int64_t nTime) |
template<typename T > | |
void | skipspaces (T &it) |
bool | IsSwitchChar (char c) |
std::string | GetArg (const std::string &strArg, const std::string &strDefault) |
Return string argument or default value. More... | |
int64_t | GetArg (const std::string &strArg, int64_t nDefault) |
Return integer argument or default value. More... | |
bool | GetBoolArg (const std::string &strArg, bool fDefault) |
Return boolean argument or default value. More... | |
bool | SoftSetArg (const std::string &strArg, const std::string &strValue) |
Set an argument if it doesn't already have a value. More... | |
bool | SoftSetBoolArg (const std::string &strArg, bool fValue) |
Set a boolean argument if it doesn't already have a value. More... | |
static uint32_t | insecure_rand (void) |
void | seed_insecure_rand (bool fDeterministic=false) |
Seed insecure_rand using the random pool. More... | |
template<typename T > | |
bool | TimingResistantEqual (const T &a, const T &b) |
Timing-attack-resistant comparison. More... | |
void | SetThreadPriority (int nPriority) |
void | RenameThread (const char *name) |
uint32_t | ByteReverse (uint32_t value) |
template<typename Callable > | |
void | LoopForever (const char *name, Callable func, int64_t msecs) |
template<typename Callable > | |
void | TraceThread (const char *name, Callable func) |
Variables | |
static const int64_t | COIN = 100000000 |
static const int64_t | CENT = 1000000 |
std::map< std::string, std::string > | mapArgs |
std::map< std::string, std::vector< std::string > > | mapMultiArgs |
bool | fDebug |
bool | fPrintToConsole |
bool | fPrintToDebugLog |
bool | fServer |
std::string | strMiscWarning |
bool | fNoListen |
bool | fLogTimestamps |
volatile bool | fReopenDebugLog |
uint32_t | insecure_rand_Rz |
MWC RNG of George Marsaglia This is intended to be fast. More... | |
uint32_t | insecure_rand_Rw |
#define ARRAYLEN | ( | array | ) | (sizeof(array)/sizeof((array)[0])) |
Definition at line 45 of file util.h.
Referenced by CInv::CInv(), CMainParams::CMainParams(), and CInv::IsKnownType().
#define BEGIN | ( | a | ) | ((char*)&(a)) |
Definition at line 41 of file util.h.
Referenced by CBlock::BuildMerkleTree(), CPartialMerkleTree::CalcHash(), CBlock::CheckMerkleBranch(), CBlockHeader::GetHash(), HexBits(), ProcessMessage(), SendMessages(), and CPartialMerkleTree::TraverseAndExtract().
#define END | ( | a | ) | ((char*)&((&(a))[1])) |
Definition at line 42 of file util.h.
Referenced by CBlock::BuildMerkleTree(), CPartialMerkleTree::CalcHash(), CBlock::CheckMerkleBranch(), CBlockHeader::GetHash(), HexBits(), ProcessMessage(), SendMessages(), and CPartialMerkleTree::TraverseAndExtract().
#define LogPrintf | ( | ... | ) | LogPrint(NULL, __VA_ARGS__) |
Definition at line 117 of file util.h.
Referenced by AbortNode(), AddLocal(), AddTimeData(), CWallet::AddToWallet(), AppInit2(), BackupWallet(), BindListenPort(), CWallet::ChangeWalletPassphrase(), CAddrMan::Check(), CheckForkWarningConditions(), CLevelDBWrapper::CLevelDBWrapper(), CWallet::CommitTransaction(), ConnectBlock(), ConnectNode(), ConnectSocketDirectly(), ConnectTip(), CreateNewBlock(), DisconnectTip(), Discover(), CWallet::EncryptWallet(), CDBEnv::EnvShutdown(), CLevelDBWrapper::Exists(), FindBlockPos(), FindUndoPos(), CWalletDB::FindWalletTx(), CWalletTx::GetAmounts(), GetMyExternalIP2(), GetNextWorkRequired(), CReserveKey::GetReservedKey(), GetTempPath(), HandleError(), importwallet(), InitBlockIndex(), BitcoinCore::initialize(), BitcoinApplication::initializeResult(), InitMessage(), InvalidChainFound(), CMessageHeader::IsValid(), CWallet::KeepKey(), LoadBlockIndexDB(), CWallet::LoadCScript(), LoadExternalBlockFile(), CWalletDB::LoadWallet(), LogException(), LoopForever(), Misbehaving(), msc_file_load(), CWallet::NewKeyPool(), noui_InitMessage(), noui_ThreadSafeMessageBox(), CDBEnv::Open(), OpenDiskFile(), COutPoint::print(), COrphan::print(), CUnsignedAlert::print(), CNetAddr::print(), CTxIn::print(), CService::print(), CInv::print(), CTxOut::print(), CTransaction::print(), CBlock::print(), CScript::print(), COutput::print(), CBlockIndex::print(), CDiskBlockIndex::print(), PrintBlockTree(), PrintExceptionContinue(), PrintHex(), CScript::PrintHex(), ProcessBlock(), ProcessGetData(), ProcessMessage(), ProcessMessages(), CLevelDBWrapper::Read(), CWalletDB::Recover(), CWalletTx::RelayWalletTransaction(), BitcoinApplication::requestInitialize(), BitcoinApplication::requestShutdown(), CWallet::ResendWalletTransactions(), CWallet::ReserveKeyFromKeyPool(), CWallet::ReturnKey(), CDB::Rewrite(), RPCAcceptHandler(), runCommand(), CDBEnv::Salvage(), CWallet::ScanForWalletTransactions(), mastercore::send_INTERNAL_1packet(), SendMessages(), CWallet::SendMoney(), ServiceConnection(), Shutdown(), BitcoinCore::shutdown(), BitcoinApplication::shutdownResult(), SignatureHash(), SocketSendData(), Socks4(), Socks5(), StartNode(), StartRPCThreads(), StopNode(), StopRPCThreads(), ThreadDNSAddressSeed(), ThreadGetMyExternalIP(), ThreadImport(), ThreadOpenConnections(), ThreadSocketHandler(), CWallet::TopUpKeyPool(), TraceThread(), UpdateTip(), VerifyDB(), BitcoinApplication::~BitcoinApplication(), and CNetCleanup::~CNetCleanup().
#define MAKE_ERROR_AND_LOG_FUNC | ( | n | ) |
#define MAX_PATH 1024 |
Definition at line 72 of file util.h.
Referenced by FormatException(), and GetTempPath().
#define MSG_NOSIGNAL 0 |
Definition at line 76 of file util.h.
Referenced by GetMyExternalIP2(), SocketSendData(), Socks4(), and Socks5().
#define PAIRTYPE | ( | t1, | |
t2 | |||
) | std::pair<t1, t2> |
Definition at line 48 of file util.h.
Referenced by CWallet::DelAddressBook(), CWallet::GetAccountAddresses(), CWalletTx::GetAccountAmounts(), CWallet::GetAddressBalances(), getaddressesbyaccount(), CWallet::GetAddressGroupings(), getbalance(), getnetworkinfo(), getrawmempool(), GetWarnings(), HTTPPost(), listaccounts(), ListReceived(), ListTransactions(), LoadBlockIndexDB(), WalletModel::loadReceiveRequests(), CWallet::MarkDirty(), ParseParameters(), CAlert::ProcessAlert(), ProcessMessage(), PaymentServer::processPaymentRequest(), CWallet::ReacceptWalletTransactions(), AddressTablePriv::refreshAddressTable(), msc_AddressTablePriv::refreshAddressTable(), CWallet::ResendWalletTransactions(), RPCTypeCheck(), ShowProgress(), Solver(), StopRPCThreads(), TransactionDesc::toHTML(), CoinControlDialog::updateView(), and WalletTxToJSON().
#define strprintf tfm::format |
Definition at line 116 of file util.h.
Referenced by _createmultisig_redeemScript(), AppInit2(), BindListenPort(), CallRPC(), CDB::CDB(), CInv::CInv(), dumpwallet(), FormatDivisibleMP(), FormatException(), mastercore::FormatIndivisibleMP(), FormatMoney(), TransactionRecord::formatSubTxId(), FormatVersion(), CInv::GetCommand(), getpeerinfo(), CRPCTable::help(), HelpMessage(), HTTPReply(), i64tostr(), CWalletTx::IMPLEMENT_SERIALIZE(), itostr(), LoopForever(), CDBEnv::MakeMock(), NetworkErrorString(), OpenDiskFile(), ProcessMessage(), ReadKeyValue(), CMPTxList::recordMetaDExCancelTX(), CMPTxList::recordPaymentTX(), CMPSTOList::recordSTOReceive(), CMPTradeList::recordTrade(), CMPTxList::recordTX(), CWalletDB::Recover(), RPCTypeCheck(), CWallet::SendMoney(), sendrawtransaction(), sendrawtx_MP(), ShowProgress(), StartRPCThreads(), mastercore::strMPProperty(), COutPoint::ToString(), CUnsignedAlert::ToString(), CTxIn::ToString(), CInv::ToString(), CTxOut::ToString(), CMPMetaDEx::ToString(), CTransaction::ToString(), CBlockFileInfo::ToString(), COutput::ToString(), CBlockIndex::ToString(), CDiskBlockIndex::ToString(), CNetAddr::ToStringIP(), CService::ToStringPort(), TraceThread(), TransactionRecord::updateStatus(), ValueString(), and CAddrDB::Write().
#define THREAD_PRIORITY_BELOW_NORMAL 2 |
Definition at line 491 of file util.h.
Referenced by ThreadMessageHandler().
|
inline |
Definition at line 257 of file util.h.
Referenced by AddTimeData().
void AddTimeData | ( | const CNetAddr & | ip, |
int64_t | nTime | ||
) |
Definition at line 1241 of file util.cpp.
References _(), abs64(), fDebug, GetTime(), CMedianFilter< T >::input(), LOCK, LogPrintf, CMedianFilter< T >::median(), CClientUIInterface::MSG_WARNING, nTimeOffset, CMedianFilter< T >::size(), CMedianFilter< T >::sorted(), strMiscWarning, and CClientUIInterface::ThreadSafeMessageBox.
Referenced by ProcessMessage().
Definition at line 1140 of file util.cpp.
Referenced by FindBlockPos(), and FindUndoPos().
|
inline |
Definition at line 242 of file util.h.
Referenced by CMPSTOList::deleteAboveBlock(), CMPTradeList::deleteAboveBlock(), eraseExpiredAccepts(), GetBoolArg(), CMPTradeList::getMatchingTrades(), CMPTxList::getMPTransactionCountBlock(), CMPTxList::getNumberOfMetaDExCancels(), CMPTxList::getNumberOfPurchases(), CMPTxList::getPurchaseDetails(), mastercore::getValidMPTX(), input_mp_accepts_string(), input_mp_crowdsale_string(), input_mp_offers_string(), input_msc_balances_string(), CMPTxList::isMPinBlockRange(), listtransactions_MP(), mscrpc(), ProcessMessage(), ReadHTTPHeaders(), ReadHTTPRequestLine(), ReadHTTPStatus(), CMPTxList::recordMetaDExCancelTX(), CMPTxList::recordPaymentTX(), and CMPTxList::setLastAlert().
|
inline |
Definition at line 224 of file util.h.
Referenced by GetArg(), ParseMoney(), and ReadOrderPos().
|
inline |
Definition at line 509 of file util.h.
Referenced by FormatHashBuffers(), and SHA256Transform().
void CreatePidFile | ( | const boost::filesystem::path & | path, |
pid_t | pid | ||
) |
std::string DateTimeStrFormat | ( | const char * | pszFormat, |
int64_t | nTime | ||
) |
Definition at line 1429 of file util.cpp.
Referenced by AppInit2(), CNode::AskFor(), mastercore::dumpCrowdsaleInfo(), EncodeDumpTime(), InvalidChainFound(), LoadBlockIndexDB(), LogPrintStr(), mastercore_init(), mastercore_shutdown(), mp_LogPrintStr(), parseTransaction(), CMPCrowd::print(), PrintBlockTree(), CMPTransaction::printInfo(), rfc1123Time(), CMPTransaction::step3_sp_variable(), CBlockFileInfo::ToString(), and UpdateTip().
std::vector<unsigned char> DecodeBase32 | ( | const char * | p, |
bool * | pfInvalid = NULL |
||
) |
Definition at line 751 of file util.cpp.
Referenced by DecodeBase32(), and CNetAddr::SetSpecial().
std::string DecodeBase32 | ( | const std::string & | str | ) |
Definition at line 868 of file util.cpp.
References DecodeBase32().
std::vector<unsigned char> DecodeBase64 | ( | const char * | p, |
bool * | pfInvalid = NULL |
||
) |
Definition at line 598 of file util.cpp.
Referenced by DecodeBase64(), HTTPAuthorized(), SignVerifyMessageDialog::on_verifyMessageButton_VM_clicked(), and verifymessage().
std::string DecodeBase64 | ( | const std::string & | str | ) |
Definition at line 681 of file util.cpp.
References DecodeBase64().
std::string EncodeBase32 | ( | const unsigned char * | pch, |
size_t | len | ||
) |
Definition at line 687 of file util.cpp.
Referenced by EncodeBase32(), and CNetAddr::ToStringIP().
std::string EncodeBase32 | ( | const std::string & | str | ) |
Definition at line 746 of file util.cpp.
References EncodeBase32().
std::string EncodeBase64 | ( | const unsigned char * | pch, |
size_t | len | ||
) |
Definition at line 547 of file util.cpp.
Referenced by CallRPC(), EncodeBase64(), SignVerifyMessageDialog::on_signMessageButton_SM_clicked(), and signmessage().
std::string EncodeBase64 | ( | const std::string & | str | ) |
Definition at line 593 of file util.cpp.
References EncodeBase64().
|
inlinestatic |
Definition at line 148 of file util.h.
References LogPrintStr().
Referenced by AcceptBlock(), AcceptToMemoryPool(), CBasicKeyStore::AddCScript(), AddToBlockIndex(), AppInit2(), CheckBlock(), CheckInputs(), CheckProofOfWork(), CAlert::CheckSignature(), CheckTransaction(), CommandLineRPC(), SSLIOStreamDevice< Protocol >::connect(), ConnectBlock(), ConnectTip(), DisconnectBlock(), DisconnectTip(), PaymentRequestPlus::getMerchant(), GetMyExternalIP2(), CCoinsViewDB::GetStats(), GetTransaction(), InitBlockIndex(), IsCanonicalPubKey(), IsCanonicalSignature(), JSONRPCError(), CBlockTreeDB::LoadBlockIndexGuts(), CDBEnv::Open(), CScriptCheck::operator()(), ProcessBlock(), ProcessMessage(), CAddrDB::Read(), ReadBlockFromDisk(), Socks4(), Socks5(), VerifyDB(), CAddrDB::Write(), and WriteBlockToDisk().
void FileCommit | ( | FILE * | fileout | ) |
Definition at line 1092 of file util.cpp.
Referenced by FlushBlockFile(), CAddrDB::Write(), and WriteBlockToDisk().
std::string FormatFullVersion | ( | ) |
Definition at line 1325 of file util.cpp.
References CLIENT_BUILD.
Referenced by AppInit(), AppInit2(), AppInitRPC(), ClientModel::formatFullVersion(), HelpMessageDialog::HelpMessageDialog(), HTTPPost(), and HTTPReply().
std::string FormatMoney | ( | int64_t | n, |
bool | fPlus = false |
||
) |
Definition at line 308 of file util.cpp.
References COIN, and strprintf.
Referenced by HelpMessage(), CWallet::SelectCoinsMinConf(), CWallet::SendMoney(), and COutput::ToString().
std::string FormatSubVersion | ( | const std::string & | name, |
int | nClientVersion, | ||
const std::vector< std::string > & | comments | ||
) |
Definition at line 1331 of file util.cpp.
References FormatVersion().
Referenced by CAlert::AppliesToMe(), and CNode::PushVersion().
int64_t GetAdjustedTime | ( | ) |
Definition at line 1236 of file util.cpp.
References GetTime(), and GetTimeOffset().
Referenced by CAddrMan::Add_(), CWallet::AddToWallet(), CheckBlock(), ConnectNode(), TransactionDesc::FormatTxStatus(), GetLocalAddress(), IsFinalTx(), CAlert::IsInEffect(), movecmd(), ProcessMessage(), CNode::PushVersion(), CAlert::RelayTo(), ThreadOpenConnections(), TransactionRecord::updateStatus(), and UpdateTime().
std::string GetArg | ( | const std::string & | strArg, |
const std::string & | strDefault | ||
) |
Return string argument or default value.
strArg | Argument to get (e.g. "-foo") |
default | (e.g. "1") |
Definition at line 505 of file util.cpp.
Referenced by AcceptToMemoryPool(), ActivateBestChain(), CWallet::AddToWallet(), AppInit2(), CNode::Ban(), CallRPC(), CheckForkWarningConditions(), CreateNewBlock(), CNode::EndMessage(), CDB::Flush(), GetConfigFile(), GetListenPort(), getmininginfo(), GetPidFile(), initTranslations(), PaymentServer::LoadRootCAs(), Misbehaving(), CWallet::NewKeyPool(), Intro::pickDataDirectory(), CAlert::ProcessAlert(), ProcessMessage(), PruneOrphanBlocks(), ReceiveFloodSize(), SendBufferSize(), CSignatureCache::Set(), StartRPCThreads(), CWallet::TopUpKeyPool(), and verifychain().
int64_t GetArg | ( | const std::string & | strArg, |
int64_t | nDefault | ||
) |
bool GetBoolArg | ( | const std::string & | strArg, |
bool | fDefault | ||
) |
Return boolean argument or default value.
strArg | Argument to get (e.g. "-foo") |
default | (true or false) |
Definition at line 519 of file util.cpp.
References atoi().
Referenced by AppInit(), AppInit2(), BitcoinGUI::BitcoinGUI(), CallRPC(), mastercore::checkExpiredAlerts(), CreateNewBlock(), CRPCTable::execute(), GetWarnings(), HelpMessage(), InitBlockIndex(), BitcoinApplication::initializeResult(), InterpretNegativeSetting(), main(), mastercore_init(), CDBEnv::Open(), Intro::pickDataDirectory(), SelectParamsFromCommandLine(), StartNode(), StartRPCThreads(), ThreadDNSAddressSeed(), and ThreadFlushWalletDB().
boost::filesystem::path GetConfigFile | ( | ) |
Definition at line 1012 of file util.cpp.
References GetArg(), and GetDataDir().
Referenced by CallRPC(), ReadConfigFile(), and StartRPCThreads().
const boost::filesystem::path& GetDataDir | ( | bool | fNetSpecific = true | ) |
Definition at line 973 of file util.cpp.
References CChainParams::DataDir(), GetDefaultDataDir(), LOCK, CChainParams::MAX_NETWORK_TYPES, CChainParams::NetworkID(), Params(), and pathCached.
Referenced by AppInit(), AppInit2(), AppInitRPC(), BackupWallet(), CAddrDB::CAddrDB(), CDB::CDB(), CheckDiskSpace(), DebugPrintInit(), mastercore::dumpCrowdsaleInfo(), GetConfigFile(), GetPidFile(), CMPTransaction::interpretPacket(), ipcServerName(), LogPrintStr(), main(), mastercore_init(), mp_DebugPrintInit(), mp_LogPrintStr(), GUIUtil::openDebugLogfile(), OpenDiskFile(), ShrinkDebugFile(), shrinkDebugFile(), StartRPCThreads(), ThreadImport(), and CAddrDB::Write().
boost::filesystem::path GetDefaultDataDir | ( | ) |
Definition at line 941 of file util.cpp.
References TryCreateDirectory().
Referenced by AppInit2(), GetDataDir(), and Intro::getDefaultDataDirectory().
|
inline |
Definition at line 298 of file util.h.
Referenced by RandAddSeed().
boost::filesystem::path GetPidFile | ( | ) |
Definition at line 1045 of file util.cpp.
References GetArg(), and GetDataDir().
Referenced by AppInit(), and Shutdown().
uint64_t GetRand | ( | uint64_t | nMax | ) |
Definition at line 186 of file util.cpp.
Referenced by mastercore::ClassB_send(), CMainParams::CMainParams(), CNode::EndMessage(), CNode::Fuzz(), GetRandInt(), ProcessMessage(), CWallet::ResendWalletTransactions(), ThreadDNSAddressSeed(), and ThreadMessageHandler().
uint256 GetRandHash | ( | ) |
Definition at line 206 of file util.cpp.
Referenced by LimitOrphanTxSize(), ProcessMessage(), SendMessages(), and CSignatureCache::Set().
Definition at line 201 of file util.cpp.
References GetRand().
Referenced by CAddrMan::Add_(), CAddrMan::GetAddr_(), CAddrMan::Good_(), CAddrMan::Select_(), CWallet::SelectCoinsMinConf(), CAddrMan::SelectTried(), and CAddrMan::ShrinkNew().
boost::filesystem::path GetTempPath | ( | ) |
int64_t GetTime | ( | ) |
Definition at line 1215 of file util.cpp.
References nMockTime.
Referenced by AcceptToMemoryPool(), AddTimeData(), AppInit2(), CNode::Ban(), CKeyPool::CKeyPool(), CMainParams::CMainParams(), CNode::CNode(), ConnectNode(), CWalletKey::CWalletKey(), mastercore::dumpCrowdsaleInfo(), dumpwallet(), CWallet::GenerateNewKey(), GetAdjustedTime(), getblocktemplate(), CWallet::GetOldestKeyPoolTime(), SendCoinsDialog::handlePaymentRequest(), CNode::IsBanned(), IsInitialBlockDownload(), LogPrintStr(), mastercore_init(), mastercore_shutdown(), mp_LogPrintStr(), ProcessMessage(), CNode::PushVersion(), RandAddSeedPerfmon(), CWalletDB::Recover(), RelayTransaction(), CWallet::ResendWalletTransactions(), rfc1123Time(), CWallet::ScanForWalletTransactions(), SendMessages(), SocketSendData(), ThreadDNSAddressSeed(), ThreadFlushWalletDB(), ThreadOpenConnections(), ThreadSocketHandler(), UpdateTip(), and walletpassphrase().
|
inline |
Definition at line 317 of file util.h.
Referenced by CNode::AskFor(), ConnectBlock(), ConnectTip(), CNode::copyStats(), DisconnectTip(), ProcessMessage(), SendMessages(), and WriteChainState().
|
inline |
Definition at line 311 of file util.h.
Referenced by AppInit2(), CWallet::ChangeWalletPassphrase(), DumpAddresses(), CWallet::EncryptWallet(), CDBEnv::Flush(), getnettotals(), LoadExternalBlockFile(), and ThreadFlushWalletDB().
int64_t GetTimeOffset | ( | ) |
Definition at line 1230 of file util.cpp.
References LOCK, and nTimeOffset.
Referenced by GetAdjustedTime(), getinfo(), and getnetworkinfo().
std::string HexStr | ( | const T | itbegin, |
const T | itend, | ||
bool | fSpaces = false |
||
) |
Definition at line 263 of file util.h.
Referenced by mastercore::ClassB_send(), createmultisig(), createrawtransaction(), EncodeDumpString(), getblock(), getblocktemplate(), getrawtransaction(), gettransaction(), HexBits(), HexStr(), CScript::mscore_getHex(), parseTransaction(), prepareObfuscatedHashes(), CMPTransaction::print(), PrintHex(), CScript::PrintHex(), ScriptPubKeyToJSON(), signrawtransaction(), CTxIn::ToString(), TxToJSON(), and ValueString().
|
inline |
|
inline |
Definition at line 214 of file util.h.
References strprintf.
Referenced by WriteOrderPos().
|
inlinestatic |
Definition at line 395 of file util.h.
References insecure_rand_Rw, and insecure_rand_Rz.
Referenced by ApproximateBestSubset(), and PruneOrphanBlocks().
bool IsHex | ( | const std::string & | str | ) |
Definition at line 409 of file util.cpp.
References HexDigit().
Referenced by _createmultisig_redeemScript(), lockunspent(), ParseHashV(), and ParseHexV().
|
inline |
Definition at line 332 of file util.h.
Referenced by AppInit(), and CommandLineRPC().
|
inline |
Definition at line 219 of file util.h.
References strprintf.
Referenced by CallRPC(), and ProcessMessage().
bool LogAcceptCategory | ( | const char * | category | ) |
Definition at line 240 of file util.cpp.
References fDebug.
Referenced by LogPrint().
void LogException | ( | std::exception * | pex, |
const char * | pszThread | ||
) |
Definition at line 927 of file util.cpp.
References FormatException(), and LogPrintf.
|
inlinestatic |
Definition at line 143 of file util.h.
References LogAcceptCategory(), and LogPrintStr().
Referenced by CNode::AbortMessage(), AcceptToMemoryPool(), CAddrMan::Add(), AddOrphanTx(), CNode::AskFor(), CCoinsViewDB::BatchWrite(), CNode::BeginMessage(), CTxMemPool::check(), CNode::CloseSocketDisconnect(), ConnectNode(), ConnectSocketDirectly(), DebugMessageHandler(), DumpAddresses(), CNode::EndMessage(), EraseOrphansFor(), CDBEnv::Flush(), CAddrMan::Good_(), CDBEnv::MakeMock(), JSONRequest::parse(), CAlert::ProcessAlert(), ProcessMessage(), CNode::PushVersion(), RandAddSeedPerfmon(), RecvLine(), CWallet::SelectCoinsMinConf(), SendMessages(), ThreadFlushWalletDB(), and ThreadSocketHandler().
int LogPrintStr | ( | const std::string & | str | ) |
Definition at line 268 of file util.cpp.
References DateTimeStrFormat(), DebugPrintInit(), debugPrintInitFlag, fileout, fLogTimestamps, fPrintToConsole, fPrintToDebugLog, fReopenDebugLog, GetDataDir(), GetTime(), and mutexDebugLog.
Referenced by error(), and LogPrint().
void LoopForever | ( | const char * | name, |
Callable | func, | ||
int64_t | msecs | ||
) |
Definition at line 522 of file util.h.
References LogPrintf, MilliSleep(), PrintExceptionContinue(), RenameThread(), and strprintf.
Referenced by StartNode().
|
inline |
Definition at line 79 of file util.h.
Referenced by BackupWallet(), CallRPC(), DetectShutdownThread(), LoopForever(), RecvLine(), CDB::Rewrite(), ServiceConnection(), StopNode(), ThreadDNSAddressSeed(), ThreadFlushWalletDB(), ThreadMessageHandler(), ThreadOpenAddedConnections(), ThreadOpenConnections(), and ThreadSocketHandler().
std::vector<unsigned char> ParseHex | ( | const char * | psz | ) |
Definition at line 419 of file util.cpp.
References HexDigit().
Referenced by _createmultisig_redeemScript(), mastercore::ClassB_send(), CMainParams::CMainParams(), CTestNetParams::CTestNetParams(), ParseHex(), ParseHexV(), parseTransaction(), CDBEnv::Salvage(), sendrawtx_MP(), and submitblock().
std::vector<unsigned char> ParseHex | ( | const std::string & | str | ) |
Definition at line 440 of file util.cpp.
References ParseHex().
bool ParseMoney | ( | const std::string & | str, |
int64_t & | nRet | ||
) |
Definition at line 332 of file util.cpp.
References ParseMoney().
Referenced by AppInit2(), and ParseMoney().
bool ParseMoney | ( | const char * | pszIn, |
int64_t & | nRet | ||
) |
void ParseParameters | ( | int | argc, |
const char *const | argv[] | ||
) |
Definition at line 460 of file util.cpp.
References InterpretNegativeSetting(), and PAIRTYPE.
Referenced by AppInit(), AppInitRPC(), and main().
void PrintExceptionContinue | ( | std::exception * | pex, |
const char * | pszThread | ||
) |
Definition at line 933 of file util.cpp.
References FormatException(), LogPrintf, and strMiscWarning.
Referenced by AppInit(), CommandLineRPC(), BitcoinCore::handleRunawayException(), LoopForever(), main(), ProcessMessages(), and TraceThread().
void PrintHex | ( | const T | pbegin, |
const T | pend, | ||
const char * | pszFormat = "%s" , |
||
bool | fSpaces = true |
||
) |
|
inline |
Definition at line 1119 of file util.cpp.
Referenced by AppInit2().
void RandAddSeed | ( | ) |
Definition at line 151 of file util.cpp.
References GetPerformanceCounter().
Referenced by CInit::CInit(), and RandAddSeedPerfmon().
void RandAddSeedPerfmon | ( | ) |
Definition at line 159 of file util.cpp.
References GetTime(), LogPrint(), and RandAddSeed().
Referenced by AppInit2(), CWallet::EncryptWallet(), CWallet::GenerateNewKey(), and ProcessMessage().
void ReadConfigFile | ( | std::map< std::string, std::string > & | mapSettingsRet, |
std::map< std::string, std::vector< std::string > > & | mapMultiSettingsRet | ||
) |
Definition at line 1019 of file util.cpp.
References ClearDatadirCache(), GetConfigFile(), and InterpretNegativeSetting().
Referenced by AppInit(), AppInitRPC(), and main().
bool RenameOver | ( | boost::filesystem::path | src, |
boost::filesystem::path | dest | ||
) |
Definition at line 1064 of file util.cpp.
Referenced by ThreadImport(), and CAddrDB::Write().
void RenameThread | ( | const char * | name | ) |
Definition at line 1388 of file util.cpp.
Referenced by LoopForever(), Shutdown(), ThreadFlushWalletDB(), ThreadImport(), ThreadScriptCheck(), and TraceThread().
|
inline |
Definition at line 252 of file util.h.
Referenced by AmountFromValue().
void runCommand | ( | std::string | strCommand | ) |
Definition at line 1381 of file util.cpp.
References LogPrintf.
Referenced by ActivateBestChain(), CWallet::AddToWallet(), CheckForkWarningConditions(), and CAlert::ProcessAlert().
std::string SanitizeString | ( | const std::string & | str | ) |
Definition at line 380 of file util.cpp.
References safeChars().
Referenced by CAlert::ProcessAlert(), and ProcessMessage().
void seed_insecure_rand | ( | bool | fDeterministic = false | ) |
Seed insecure_rand using the random pool.
Deterministic | Use a determinstic seed |
Definition at line 1298 of file util.cpp.
References insecure_rand_Rw, and insecure_rand_Rz.
Referenced by ApproximateBestSubset().
void SetMockTime | ( | int64_t | nMockTimeIn | ) |
|
inline |
Definition at line 495 of file util.h.
Referenced by ThreadMessageHandler().
void SetupEnvironment | ( | ) |
void ShrinkDebugFile | ( | ) |
Definition at line 1182 of file util.cpp.
References GetDataDir().
Referenced by AppInit2().
bool SoftSetArg | ( | const std::string & | strArg, |
const std::string & | strValue | ||
) |
Set an argument if it doesn't already have a value.
strArg | Argument to set (e.g. "-foo") |
strValue | Value (e.g. "1") |
Definition at line 530 of file util.cpp.
Referenced by OptionsModel::Init(), Intro::pickDataDirectory(), and SoftSetBoolArg().
bool SoftSetBoolArg | ( | const std::string & | strArg, |
bool | fValue | ||
) |
Set a boolean argument if it doesn't already have a value.
strArg | Argument to set (e.g. "-foo") |
fValue | Value (e.g. false) |
Definition at line 538 of file util.cpp.
References SoftSetArg().
Referenced by AppInit(), AppInit2(), OptionsModel::Init(), and CWalletDB::LoadWallet().
bool TimingResistantEqual | ( | const T & | a, |
const T & | b | ||
) |
Timing-attack-resistant comparison.
Takes time proportional to length of first argument.
Definition at line 414 of file util.h.
Referenced by HTTPAuthorized().
void TraceThread | ( | const char * | name, |
Callable | func | ||
) |
Definition at line 550 of file util.h.
References LogPrintf, PrintExceptionContinue(), RenameThread(), and strprintf.
Referenced by Discover(), and StartNode().
bool TruncateFile | ( | FILE * | file, |
unsigned int | length | ||
) |
Definition at line 1109 of file util.cpp.
Referenced by FlushBlockFile().
bool TryCreateDirectory | ( | const boost::filesystem::path & | p | ) |
Definition at line 1078 of file util.cpp.
Referenced by CLevelDBWrapper::CLevelDBWrapper(), GetDefaultDataDir(), CDBEnv::Open(), and Intro::pickDataDirectory().
bool WildcardMatch | ( | const char * | psz, |
const char * | mask | ||
) |
Definition at line 875 of file util.cpp.
References WildcardMatch().
Referenced by ClientAllowed(), and WildcardMatch().
bool WildcardMatch | ( | const std::string & | str, |
const std::string & | mask | ||
) |
Definition at line 899 of file util.cpp.
References WildcardMatch().
|
static |
Definition at line 39 of file util.h.
Referenced by GetMinFee(), ParseMoney(), CWallet::SelectCoinsMinConf(), and CoinControlDialog::updateLabels().
|
static |
Definition at line 38 of file util.h.
Referenced by AllowFree(), AmountFromValue(), CMainParams::CMainParams(), FormatDivisibleMP(), FormatMoney(), getactivedexsells_MP(), GetBlockValue(), getreceivedbyaccount(), CMPTransaction::logicMath_GrantTokens(), CMPTransaction::logicMath_SendToOwners(), CMPTransaction::logicMath_TradeOffer(), ParseMoney(), parseTransaction(), CMPAccept::print(), CMPTransaction::print(), selectCoins(), send_MP(), CMPTransaction::step3_sp_fixed(), CMPTransaction::step3_sp_variable(), CTxOut::ToString(), TXExodusFundraiser(), and ValueFromAmount().
bool fDebug |
Definition at line 91 of file util.cpp.
Referenced by AddTimeData(), AppInit2(), CreateNewBlock(), LogAcceptCategory(), ProcessMessage(), SendMessages(), and TransactionDesc::toHTML().
bool fLogTimestamps |
Definition at line 98 of file util.cpp.
Referenced by AppInit2(), LogPrintStr(), and mp_LogPrintStr().
bool fNoListen |
Definition at line 97 of file util.cpp.
Referenced by AppInit2(), GetLocal(), ProcessMessage(), and SendMessages().
bool fPrintToConsole |
Definition at line 92 of file util.cpp.
Referenced by AppInit2(), LogPrintStr(), and mp_LogPrintStr().
bool fPrintToDebugLog |
Definition at line 93 of file util.cpp.
Referenced by LogPrintStr(), and mp_LogPrintStr().
volatile bool fReopenDebugLog |
Definition at line 99 of file util.cpp.
Referenced by HandleSIGHUP(), LogPrintStr(), and mp_LogPrintStr().
bool fServer |
Definition at line 95 of file util.cpp.
Referenced by AppInit2().
uint32_t insecure_rand_Rw |
Definition at line 1297 of file util.cpp.
Referenced by insecure_rand(), and seed_insecure_rand().
uint32_t insecure_rand_Rz |
MWC RNG of George Marsaglia This is intended to be fast.
It has a period of 2^59.3, though the least significant 16 bits only have a period of about 2^30.1.
Definition at line 1296 of file util.cpp.
Referenced by insecure_rand(), and seed_insecure_rand().
std::map<std::string, std::string> mapArgs |
Definition at line 89 of file util.cpp.
Referenced by OptionsModel::addOverriddenOption(), AppInit(), AppInit2(), AppInitRPC(), CallRPC(), CNode::EndMessage(), OptionsModel::Init(), main(), ProcessMessage(), ServiceConnection(), StartRPCThreads(), and ThreadOpenConnections().
std::map<std::string, std::vector<std::string> > mapMultiArgs |
Definition at line 90 of file util.cpp.
Referenced by AppInit(), AppInit2(), AppInitRPC(), ClientAllowed(), main(), ThreadOpenAddedConnections(), and ThreadOpenConnections().
std::string strMiscWarning |
Definition at line 96 of file util.cpp.
Referenced by AbortNode(), AddTimeData(), GetWarnings(), BitcoinCore::handleRunawayException(), main(), PrintExceptionContinue(), and UpdateTip().