Skip to content
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

Add log category: accountchange #1144

Merged
merged 5 commits into from
Mar 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ const CLogCategoryDesc LogCategories[] =
{BCLog::SPV, "spv"},
{BCLog::ORACLE, "oracle"},
{BCLog::LOAN, "loan"},
{BCLog::ACCOUNTCHANGE, "accountchange"},
{BCLog::ALL, "1"},
{BCLog::ALL, "all"},
};
Expand Down
55 changes: 28 additions & 27 deletions src/logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,33 +32,34 @@ struct CLogCategoryActive

namespace BCLog {
enum LogFlags : uint32_t {
NONE = 0,
NET = (1 << 0),
TOR = (1 << 1),
MEMPOOL = (1 << 2),
HTTP = (1 << 3),
BENCH = (1 << 4),
ZMQ = (1 << 5),
DB = (1 << 6),
RPC = (1 << 7),
ESTIMATEFEE = (1 << 8),
ADDRMAN = (1 << 9),
SELECTCOINS = (1 << 10),
REINDEX = (1 << 11),
CMPCTBLOCK = (1 << 12),
RAND = (1 << 13),
PRUNE = (1 << 14),
PROXY = (1 << 15),
MEMPOOLREJ = (1 << 16),
LIBEVENT = (1 << 17),
COINDB = (1 << 18),
LEVELDB = (1 << 20),
STAKING = (1 << 21),
ANCHORING = (1 << 22),
SPV = (1 << 23),
ORACLE = (1 << 24),
LOAN = (1 << 25),
ALL = ~(uint32_t)0,
NONE = 0,
NET = (1 << 0),
TOR = (1 << 1),
MEMPOOL = (1 << 2),
HTTP = (1 << 3),
BENCH = (1 << 4),
ZMQ = (1 << 5),
DB = (1 << 6),
RPC = (1 << 7),
ESTIMATEFEE = (1 << 8),
ADDRMAN = (1 << 9),
SELECTCOINS = (1 << 10),
REINDEX = (1 << 11),
CMPCTBLOCK = (1 << 12),
RAND = (1 << 13),
PRUNE = (1 << 14),
PROXY = (1 << 15),
MEMPOOLREJ = (1 << 16),
LIBEVENT = (1 << 17),
COINDB = (1 << 18),
LEVELDB = (1 << 20),
STAKING = (1 << 21),
ANCHORING = (1 << 22),
SPV = (1 << 23),
ORACLE = (1 << 24),
LOAN = (1 << 25),
ACCOUNTCHANGE = (1 << 26),
ALL = ~(uint32_t)0,
};

class Logger
Expand Down
3 changes: 3 additions & 0 deletions src/masternodes/accountshistory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ void CHistoryErasers::Flush(const uint32_t height, const uint32_t txn, const uin
CHistoryWriters::CHistoryWriters(CAccountHistoryStorage* historyView, CBurnHistoryStorage* burnView, CVaultHistoryStorage* vaultView)
: historyView(historyView), burnView(burnView), vaultView(vaultView) {}

extern std::string ScriptToString(CScript const& script);

void CHistoryWriters::AddBalance(const CScript& owner, const CTokenAmount amount, const uint256& vaultID)
{
if (historyView) {
Expand Down Expand Up @@ -188,6 +190,7 @@ void CHistoryWriters::Flush(const uint32_t height, const uint256& txid, const ui
{
if (historyView) {
for (const auto& diff : diffs) {
LogPrint(BCLog::ACCOUNTCHANGE, "AccountChange: txid=%s addr=%s change=%s\n", txid.GetHex(), ScriptToString(diff.first), (CBalances{diff.second}.ToString()));
historyView->WriteAccountHistory({diff.first, height, txn}, {txid, type, diff.second});
}
}
Expand Down