mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Access Journal::Stream using member functions (RIPD-1087):
Replace Journal public data members with member function accessors in order to make Journal lighter weight. The change makes a Journal cheaper to pass by value. Also add missing stream checks (e.g., calls to JLOG) to avoid text processing that ultimately will not be stored in the log.
This commit is contained in:
@@ -127,7 +127,7 @@ accountHolds (ReadView const& view,
|
||||
amount.clear ();
|
||||
else
|
||||
amount = balance - reserve;
|
||||
JLOG (j.trace) << "accountHolds:" <<
|
||||
JLOG (j.trace()) << "accountHolds:" <<
|
||||
" account=" << to_string (account) <<
|
||||
" amount=" << amount.getFullText () <<
|
||||
" balance=" << to_string (balance) <<
|
||||
@@ -157,7 +157,7 @@ accountHolds (ReadView const& view,
|
||||
}
|
||||
amount.setIssuer (issuer);
|
||||
}
|
||||
JLOG (j.trace) << "accountHolds:" <<
|
||||
JLOG (j.trace()) << "accountHolds:" <<
|
||||
" account=" << to_string (account) <<
|
||||
" amount=" << amount.getFullText ();
|
||||
}
|
||||
@@ -177,7 +177,7 @@ accountFunds (ReadView const& view, AccountID const& id,
|
||||
saDefault.getIssuer () == id)
|
||||
{
|
||||
saFunds = saDefault;
|
||||
JLOG (j.trace) << "accountFunds:" <<
|
||||
JLOG (j.trace()) << "accountFunds:" <<
|
||||
" account=" << to_string (id) <<
|
||||
" saDefault=" << saDefault.getFullText () <<
|
||||
" SELF-FUNDED";
|
||||
@@ -187,7 +187,7 @@ accountFunds (ReadView const& view, AccountID const& id,
|
||||
saFunds = accountHolds(view, id,
|
||||
saDefault.getCurrency(), saDefault.getIssuer(),
|
||||
freezeHandling, j);
|
||||
JLOG (j.trace) << "accountFunds:" <<
|
||||
JLOG (j.trace()) << "accountFunds:" <<
|
||||
" account=" << to_string (id) <<
|
||||
" saDefault=" << saDefault.getFullText () <<
|
||||
" saFunds=" << saFunds.getFullText ();
|
||||
@@ -461,7 +461,7 @@ cdirNext (ReadView const& view,
|
||||
if (!sleNext)
|
||||
{
|
||||
// This should never happen
|
||||
JLOG (j.fatal)
|
||||
JLOG (j.fatal())
|
||||
<< "Corrupt directory: index:"
|
||||
<< uRootIndex << " next:" << uNodeNext;
|
||||
return false;
|
||||
@@ -471,7 +471,7 @@ cdirNext (ReadView const& view,
|
||||
sleNode, uDirEntry, uEntryIndex, j);
|
||||
}
|
||||
uEntryIndex = svIndexes[uDirEntry++];
|
||||
JLOG (j.trace) << "dirNext:" <<
|
||||
JLOG (j.trace()) << "dirNext:" <<
|
||||
" uDirEntry=" << uDirEntry <<
|
||||
" uEntryIndex=" << uEntryIndex;
|
||||
return true;
|
||||
@@ -524,7 +524,7 @@ hashOfSeq (ReadView const& ledger, LedgerIndex seq,
|
||||
// Easy cases...
|
||||
if (seq > ledger.seq())
|
||||
{
|
||||
JLOG (journal.warning) <<
|
||||
JLOG (journal.warn()) <<
|
||||
"Can't get seq " << seq <<
|
||||
" from " << ledger.seq() << " future";
|
||||
return boost::none;
|
||||
@@ -548,21 +548,21 @@ hashOfSeq (ReadView const& ledger, LedgerIndex seq,
|
||||
STVector256 vec = hashIndex->getFieldV256 (sfHashes);
|
||||
if (vec.size () >= diff)
|
||||
return vec[vec.size () - diff];
|
||||
JLOG (journal.warning) <<
|
||||
JLOG (journal.warn()) <<
|
||||
"Ledger " << ledger.seq() <<
|
||||
" missing hash for " << seq <<
|
||||
" (" << vec.size () << "," << diff << ")";
|
||||
}
|
||||
else
|
||||
{
|
||||
JLOG (journal.warning) <<
|
||||
JLOG (journal.warn()) <<
|
||||
"Ledger " << ledger.seq() <<
|
||||
":" << ledger.info().hash << " missing normal list";
|
||||
}
|
||||
}
|
||||
if ((seq & 0xff) != 0)
|
||||
{
|
||||
JLOG (journal.debug) <<
|
||||
JLOG (journal.debug()) <<
|
||||
"Can't get seq " << seq <<
|
||||
" from " << ledger.seq() << " past";
|
||||
return boost::none;
|
||||
@@ -583,7 +583,7 @@ hashOfSeq (ReadView const& ledger, LedgerIndex seq,
|
||||
if (vec.size () > diff)
|
||||
return vec[vec.size () - diff - 1];
|
||||
}
|
||||
JLOG (journal.warning) <<
|
||||
JLOG (journal.warn()) <<
|
||||
"Can't get seq " << seq <<
|
||||
" from " << ledger.seq() << " error";
|
||||
return boost::none;
|
||||
@@ -609,7 +609,7 @@ adjustOwnerCount (ApplyView& view,
|
||||
// Overflow is well defined on unsigned
|
||||
if (adjusted < current)
|
||||
{
|
||||
JLOG (j.fatal) <<
|
||||
JLOG (j.fatal()) <<
|
||||
"Account " << sle->getAccountID(sfAccount) <<
|
||||
" owner count exceeds max!";
|
||||
adjusted =
|
||||
@@ -621,7 +621,7 @@ adjustOwnerCount (ApplyView& view,
|
||||
// Underflow is well defined on unsigned
|
||||
if (adjusted > current)
|
||||
{
|
||||
JLOG (j.fatal) <<
|
||||
JLOG (j.fatal()) <<
|
||||
"Account " << sle->getAccountID (sfAccount) <<
|
||||
" owner count set below 0!";
|
||||
adjusted = 0;
|
||||
@@ -671,7 +671,7 @@ dirNext (ApplyView& view,
|
||||
if (!sleNext)
|
||||
{
|
||||
// This should never happen
|
||||
JLOG (j.fatal)
|
||||
JLOG (j.fatal())
|
||||
<< "Corrupt directory: index:"
|
||||
<< uRootIndex << " next:" << uNodeNext;
|
||||
return false;
|
||||
@@ -681,7 +681,7 @@ dirNext (ApplyView& view,
|
||||
sleNode, uDirEntry, uEntryIndex, j);
|
||||
}
|
||||
uEntryIndex = svIndexes[uDirEntry++];
|
||||
JLOG (j.trace) << "dirNext:" <<
|
||||
JLOG (j.trace()) << "dirNext:" <<
|
||||
" uDirEntry=" << uDirEntry <<
|
||||
" uEntryIndex=" << uEntryIndex;
|
||||
return true;
|
||||
@@ -704,7 +704,7 @@ dirAdd (ApplyView& view,
|
||||
std::function<void (SLE::ref, bool)> fDescriber,
|
||||
beast::Journal j)
|
||||
{
|
||||
JLOG (j.trace) << "dirAdd:" <<
|
||||
JLOG (j.trace()) << "dirAdd:" <<
|
||||
" uRootIndex=" << to_string (uRootIndex) <<
|
||||
" uLedgerIndex=" << to_string (uLedgerIndex);
|
||||
|
||||
@@ -780,11 +780,11 @@ dirAdd (ApplyView& view,
|
||||
svIndexes.push_back (uLedgerIndex); // Append entry.
|
||||
sleNode->setFieldV256 (sfIndexes, svIndexes); // Save entry.
|
||||
|
||||
JLOG (j.trace) <<
|
||||
JLOG (j.trace()) <<
|
||||
"dirAdd: creating: root: " << to_string (uRootIndex);
|
||||
JLOG (j.trace) <<
|
||||
JLOG (j.trace()) <<
|
||||
"dirAdd: appending: Entry: " << to_string (uLedgerIndex);
|
||||
JLOG (j.trace) <<
|
||||
JLOG (j.trace()) <<
|
||||
"dirAdd: appending: Node: " << strHex (uNodeDir);
|
||||
|
||||
return tesSUCCESS;
|
||||
@@ -807,7 +807,7 @@ dirDelete (ApplyView& view,
|
||||
|
||||
if (!sleNode)
|
||||
{
|
||||
JLOG (j.warning) << "dirDelete: no such node:" <<
|
||||
JLOG (j.warn()) << "dirDelete: no such node:" <<
|
||||
" uRootIndex=" << to_string (uRootIndex) <<
|
||||
" uNodeDir=" << strHex (uNodeDir) <<
|
||||
" uLedgerIndex=" << to_string (uLedgerIndex);
|
||||
@@ -839,7 +839,7 @@ dirDelete (ApplyView& view,
|
||||
if (!bSoft)
|
||||
{
|
||||
assert (false);
|
||||
JLOG (j.warning) << "dirDelete: no such entry";
|
||||
JLOG (j.warn()) << "dirDelete: no such entry";
|
||||
return tefBAD_LEDGER;
|
||||
}
|
||||
|
||||
@@ -929,13 +929,13 @@ dirDelete (ApplyView& view,
|
||||
assert (slePrevious);
|
||||
if (!slePrevious)
|
||||
{
|
||||
JLOG (j.warning) << "dirDelete: previous node is missing";
|
||||
JLOG (j.warn()) << "dirDelete: previous node is missing";
|
||||
return tefBAD_LEDGER;
|
||||
}
|
||||
assert (sleNext);
|
||||
if (!sleNext)
|
||||
{
|
||||
JLOG (j.warning) << "dirDelete: next node is missing";
|
||||
JLOG (j.warn()) << "dirDelete: next node is missing";
|
||||
return tefBAD_LEDGER;
|
||||
}
|
||||
|
||||
@@ -997,7 +997,7 @@ trustCreate (ApplyView& view,
|
||||
std::uint32_t uQualityOut,
|
||||
beast::Journal j)
|
||||
{
|
||||
JLOG (j.trace)
|
||||
JLOG (j.trace())
|
||||
<< "trustCreate: " << to_string (uSrcAccountID) << ", "
|
||||
<< to_string (uDstAccountID) << ", " << saBalance.getFullText ();
|
||||
|
||||
@@ -1112,7 +1112,7 @@ trustDelete (ApplyView& view,
|
||||
std::uint64_t uHighNode = sleRippleState->getFieldU64 (sfHighNode);
|
||||
TER terResult;
|
||||
|
||||
JLOG (j.trace)
|
||||
JLOG (j.trace())
|
||||
<< "trustDelete: Deleting ripple line: low";
|
||||
terResult = dirDelete(view,
|
||||
false,
|
||||
@@ -1125,7 +1125,7 @@ trustDelete (ApplyView& view,
|
||||
|
||||
if (tesSUCCESS == terResult)
|
||||
{
|
||||
JLOG (j.trace)
|
||||
JLOG (j.trace())
|
||||
<< "trustDelete: Deleting ripple line: high";
|
||||
terResult = dirDelete (view,
|
||||
false,
|
||||
@@ -1137,7 +1137,7 @@ trustDelete (ApplyView& view,
|
||||
j);
|
||||
}
|
||||
|
||||
JLOG (j.trace) << "trustDelete: Deleting ripple line: state";
|
||||
JLOG (j.trace()) << "trustDelete: Deleting ripple line: state";
|
||||
view.erase(sleRippleState);
|
||||
|
||||
return terResult;
|
||||
@@ -1212,7 +1212,7 @@ rippleCredit (ApplyView& view,
|
||||
|
||||
saBalance.setIssuer (noAccount());
|
||||
|
||||
JLOG (j.debug) << "rippleCredit: "
|
||||
JLOG (j.debug()) << "rippleCredit: "
|
||||
"create line: " << to_string (uSenderID) <<
|
||||
" -> " << to_string (uReceiverID) <<
|
||||
" : " << saAmount.getFullText ();
|
||||
@@ -1251,7 +1251,7 @@ rippleCredit (ApplyView& view,
|
||||
|
||||
saBalance -= saAmount;
|
||||
|
||||
JLOG (j.trace) << "rippleCredit: " <<
|
||||
JLOG (j.trace()) << "rippleCredit: " <<
|
||||
to_string (uSenderID) <<
|
||||
" -> " << to_string (uReceiverID) <<
|
||||
" : before=" << saBefore.getFullText () <<
|
||||
@@ -1340,7 +1340,7 @@ rippleTransferFee (ReadView const& view,
|
||||
saAmount, amountFromRate (uTransitRate), saAmount.issue ());
|
||||
STAmount saTransferFee = saTransferTotal - saAmount;
|
||||
|
||||
JLOG (j.debug) << "rippleTransferFee:" <<
|
||||
JLOG (j.debug()) << "rippleTransferFee:" <<
|
||||
" saTransferFee=" << saTransferFee.getFullText ();
|
||||
|
||||
return saTransferFee;
|
||||
@@ -1394,7 +1394,7 @@ rippleSend (ApplyView& view,
|
||||
multiply (saAmount, amountFromRate (rate), saAmount.issue ());
|
||||
}
|
||||
|
||||
JLOG (j.debug) << "rippleSend> " <<
|
||||
JLOG (j.debug()) << "rippleSend> " <<
|
||||
to_string (uSenderID) <<
|
||||
" - > " << to_string (uReceiverID) <<
|
||||
" : deliver=" << saAmount.getFullText () <<
|
||||
@@ -1425,7 +1425,7 @@ accountSend (ApplyView& view,
|
||||
{
|
||||
STAmount saActual;
|
||||
|
||||
JLOG (j.trace) << "accountSend: " <<
|
||||
JLOG (j.trace()) << "accountSend: " <<
|
||||
to_string (uSenderID) << " -> " << to_string (uReceiverID) <<
|
||||
" : " << saAmount.getFullText ();
|
||||
|
||||
@@ -1450,7 +1450,7 @@ accountSend (ApplyView& view,
|
||||
? view.peek (keylet::account(uReceiverID))
|
||||
: SLE::pointer ();
|
||||
|
||||
if (j.trace)
|
||||
if (auto stream = j.trace())
|
||||
{
|
||||
std::string sender_bal ("-");
|
||||
std::string receiver_bal ("-");
|
||||
@@ -1461,7 +1461,7 @@ accountSend (ApplyView& view,
|
||||
if (receiver)
|
||||
receiver_bal = receiver->getFieldAmount (sfBalance).getFullText ();
|
||||
|
||||
j.trace << "accountSend> " <<
|
||||
stream << "accountSend> " <<
|
||||
to_string (uSenderID) << " (" << sender_bal <<
|
||||
") -> " << to_string (uReceiverID) << " (" << receiver_bal <<
|
||||
") : " << saAmount.getFullText ();
|
||||
@@ -1494,7 +1494,7 @@ accountSend (ApplyView& view,
|
||||
view.update (receiver);
|
||||
}
|
||||
|
||||
if (j.trace)
|
||||
if (auto stream = j.trace())
|
||||
{
|
||||
std::string sender_bal ("-");
|
||||
std::string receiver_bal ("-");
|
||||
@@ -1505,7 +1505,7 @@ accountSend (ApplyView& view,
|
||||
if (receiver)
|
||||
receiver_bal = receiver->getFieldAmount (sfBalance).getFullText ();
|
||||
|
||||
j.trace << "accountSend< " <<
|
||||
stream << "accountSend< " <<
|
||||
to_string (uSenderID) << " (" << sender_bal <<
|
||||
") -> " << to_string (uReceiverID) << " (" << receiver_bal <<
|
||||
") : " << saAmount.getFullText ();
|
||||
@@ -1580,7 +1580,7 @@ issueIOU (ApplyView& view,
|
||||
// Can't send to self!
|
||||
assert (issue.account != account);
|
||||
|
||||
JLOG (j.trace) << "issueIOU: " <<
|
||||
JLOG (j.trace()) << "issueIOU: " <<
|
||||
to_string (account) << ": " <<
|
||||
amount.getFullText ();
|
||||
|
||||
@@ -1654,7 +1654,7 @@ redeemIOU (ApplyView& view,
|
||||
// Can't send to self!
|
||||
assert (issue.account != account);
|
||||
|
||||
JLOG (j.trace) << "redeemIOU: " <<
|
||||
JLOG (j.trace()) << "redeemIOU: " <<
|
||||
to_string (account) << ": " <<
|
||||
amount.getFullText ();
|
||||
|
||||
@@ -1668,7 +1668,7 @@ redeemIOU (ApplyView& view,
|
||||
// In order to hold an IOU, a trust line *MUST* exist to track the
|
||||
// balance. If it doesn't, then something is very wrong. Don't try
|
||||
// to continue.
|
||||
JLOG (j.fatal) << "redeemIOU: " <<
|
||||
JLOG (j.fatal()) << "redeemIOU: " <<
|
||||
to_string (account) << " attempts to redeem " <<
|
||||
amount.getFullText () << " but no trust line exists!";
|
||||
|
||||
@@ -1724,7 +1724,7 @@ transferXRP (ApplyView& view,
|
||||
SLE::pointer sender = view.peek (keylet::account(from));
|
||||
SLE::pointer receiver = view.peek (keylet::account(to));
|
||||
|
||||
JLOG (j.trace) << "transferXRP: " <<
|
||||
JLOG (j.trace()) << "transferXRP: " <<
|
||||
to_string (from) << " -> " << to_string (to) <<
|
||||
") : " << amount.getFullText ();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user