Skip to content

Commit

Permalink
Add log category: accountchange (#1144)
Browse files Browse the repository at this point in the history
* Add log category: accountchange

* Fix lint

* Remove add/subBalance from ACCOUNTCHANGE log category

* Use CBalances ToString method

Co-authored-by: Prasanna Loganathar <pvl@prasannavl.com>
  • Loading branch information
Jouzo and prasannavl authored Mar 18, 2022
1 parent 144e9bc commit 8aee91e
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 27 deletions.
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

0 comments on commit 8aee91e

Please sign in to comment.