mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Reduce the peer charges for well-behaved peers:
- Fix an erroneous high fee penalty that peers could incur for sending
older transactions.
- Update to the fees charged for imposing a load on the server.
- Prevent the relaying of internal pseudo-transactions.
- Before: Pseudo-transactions received from a peer will fail the signature
check, even if they were requested (using TMGetObjectByHash), because
they have no signature. This causes the peer to be charge for an
invalid signature.
- After: Pseudo-transactions, are put into the global cache
(TransactionMaster) only. If the transaction is not part of
a TMTransactions batch, the peer is charged an unwanted data fee.
These fees will not be a problem in the normal course of operations,
but should dissuade peers from behaving badly by sending a bunch of
junk.
- Improve logging: include the reason for fees charged to a peer.
Co-authored-by: Ed Hennis <ed@ripple.com>
This commit is contained in:
committed by
tequ
parent
ee78f8d566
commit
dd4b060f09
@@ -442,12 +442,34 @@ public:
|
||||
}
|
||||
|
||||
Disposition
|
||||
charge(Entry& entry, Charge const& fee)
|
||||
charge(Entry& entry, Charge const& fee, std::string context = {})
|
||||
{
|
||||
static constexpr Charge::value_type feeLogAsWarn = 3000;
|
||||
static constexpr Charge::value_type feeLogAsInfo = 1000;
|
||||
static constexpr Charge::value_type feeLogAsDebug = 100;
|
||||
static_assert(
|
||||
feeLogAsWarn > feeLogAsInfo && feeLogAsInfo > feeLogAsDebug &&
|
||||
feeLogAsDebug > 10);
|
||||
|
||||
static auto getStream = [](Resource::Charge::value_type cost,
|
||||
beast::Journal& journal) {
|
||||
if (cost >= feeLogAsWarn)
|
||||
return journal.warn();
|
||||
if (cost >= feeLogAsInfo)
|
||||
return journal.info();
|
||||
if (cost >= feeLogAsDebug)
|
||||
return journal.debug();
|
||||
return journal.trace();
|
||||
};
|
||||
|
||||
if (!context.empty())
|
||||
context = " (" + context + ")";
|
||||
|
||||
std::lock_guard _(lock_);
|
||||
clock_type::time_point const now(m_clock.now());
|
||||
int const balance(entry.add(fee.cost(), now));
|
||||
JLOG(m_journal.trace()) << "Charging " << entry << " for " << fee;
|
||||
JLOG(getStream(fee.cost(), m_journal))
|
||||
<< "Charging " << entry << " for " << fee << context;
|
||||
return disposition(balance);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user