Limit changed node count

This commit is contained in:
JoelKatz
2015-09-07 08:57:02 -07:00
committed by Nik Bougalis
parent 91eee1a42d
commit 88f885f2e7
10 changed files with 56 additions and 1 deletions

View File

@@ -532,7 +532,11 @@ Transactor::operator()()
bool didApply = isTesSuccess (terResult);
auto fee = tx().getTransactionFee ();
if (isTecClaim (terResult) && !(view().flags() & tapRETRY))
if (view().size() > 5200)
terResult = tecOVERSIZE;
if ((terResult == tecOVERSIZE) ||
(isTecClaim (terResult) && !(view().flags() & tapRETRY)))
{
// only claim the transaction fee
JLOG(j_.debug) <<

View File

@@ -196,6 +196,12 @@ public:
void
update (std::shared_ptr<SLE> const& sle) = 0;
/** Get the number of modified entries
*/
virtual
std::size_t
size () = 0;
//--------------------------------------------------------------------------
// Called when a credit is made to an account

View File

@@ -80,6 +80,11 @@ public:
deliver_ = amount;
}
/** Get the number of modified entries
*/
std::size_t
size ();
private:
boost::optional<STAmount> deliver_;
};

View File

@@ -94,6 +94,9 @@ public:
peek (ReadView const& base,
Keylet const& k);
std::size_t
size ();
void
erase (ReadView const& base,
std::shared_ptr<SLE> const& sle);

View File

@@ -132,6 +132,9 @@ public:
rawDestroyXRP (
std::uint64_t feeDrops) override;
std::size_t
size () override;
protected:
ApplyFlags flags_;
ReadView const* base_;

View File

@@ -53,6 +53,25 @@ ApplyStateTable::apply (RawView& to) const
}
}
std::size_t
ApplyStateTable::size ()
{
std::size_t ret = 0;
for (auto& item : items_)
{
switch (item.second.first)
{
case Action::erase:
case Action::insert:
case Action::modify:
++ret;
default:
break;
}
}
return ret;
}
void
ApplyStateTable::apply (OpenView& to,
STTx const& tx, TER ter,

View File

@@ -148,6 +148,13 @@ ApplyViewBase::update(
items_.update(*base_, sle);
}
std::size_t
ApplyViewBase::size ()
{
return items_.size ();
}
//---
void

View File

@@ -38,4 +38,10 @@ ApplyViewImpl::apply (OpenView& to,
items_.apply(to, tx, ter, deliver_, j);
}
std::size_t
ApplyViewImpl::size ()
{
return items_.size ();
}
} // ripple

View File

@@ -200,6 +200,7 @@ enum TER
tecNEED_MASTER_KEY = 142,
tecDST_TAG_NEEDED = 143,
tecINTERNAL = 144,
tecOVERSIZE = 145,
};
inline bool isTelLocal(TER x)

View File

@@ -50,6 +50,7 @@ bool transResultInfo (TER code, std::string& token, std::string& text)
{ tecPATH_PARTIAL, "tecPATH_PARTIAL", "Path could not send full amount." },
{ tecNO_ALTERNATIVE_KEY, "tecNO_ALTERNATIVE_KEY", "The operation would remove the last way to sign a transaction."},
{ tecNO_REGULAR_KEY, "tecNO_REGULAR_KEY", "Regular key is not set." },
{ tecOVERSIZE, "tecOVERSIZE", "Object exceeded serialization limits." },
{ tecUNFUNDED, "tecUNFUNDED", "One of _ADD, _OFFER, or _SEND. Deprecated." },
{ tecUNFUNDED_ADD, "tecUNFUNDED_ADD", "Insufficient XRP balance for WalletAdd." },