Put OfferCreate bug fix on a ledger switch:

The fix for an off-by one bug that overstates the account reserve
during OfferCreate is set to become active on August 3rd. Before
this date, the program will exhibit the old behavior.
This commit is contained in:
Vinnie Falco
2015-07-17 10:21:32 -07:00
parent 5ec3534fea
commit f41fc87a33
3 changed files with 11 additions and 0 deletions

View File

@@ -421,6 +421,13 @@ CreateOffer::format_amount (STAmount const& amount)
STAmount
CreateOffer::getAccountReserve (SLE::pointer account)
{
// Mon Aug 3 11:00:00am PDT
static NetClock::time_point const switchoverTime (
std::chrono::seconds (491940000));
if (ctx_.view().info().parentCloseTime <=
switchoverTime.time_since_epoch().count())
return STAmount (ctx_.view().fees().accountReserve(
deprecatedWrongOwnerCount_+1));
return STAmount (ctx_.view().fees().accountReserve(
account->getFieldU32 (sfOwnerCount) + 1));
}
@@ -559,6 +566,8 @@ CreateOffer::applyGuts (ApplyView& view, ApplyView& view_cancel)
auto const sleCreator = view.peek (
keylet::account(account_));
deprecatedWrongOwnerCount_ = sleCreator->getFieldU32(sfOwnerCount);
std::uint32_t const uAccountSequenceNext = sleCreator->getFieldU32 (sfSequence);
std::uint32_t const uSequence = mTxn.getSequence ();

View File

@@ -112,6 +112,7 @@ private:
private:
// What kind of offer we are placing
CrossType cross_type_;
std::uint32_t deprecatedWrongOwnerCount_;
};
}

View File

@@ -21,6 +21,7 @@
#define RIPPLE_LEDGER_READVIEW_H_INCLUDED
#include <ripple/ledger/detail/ReadViewFwdRange.h>
#include <ripple/basics/chrono.h>
#include <ripple/protocol/Indexes.h>
#include <ripple/protocol/Protocol.h>
#include <ripple/protocol/STLedgerEntry.h>