Tx queue enhancements and RPC info (RIPD-1205, RIPD-1206):

* Account-related queue stats (RIPD-1205). Boolean "queue" parameter to
  account_info only if requesting the open ledger.
* Account for the TxQ when autofilling sequence in sign-and-submit (RIPD-1206)
* Tweak TxQ::accept edge case when choosing which tx to try next.
* Labels for experimental "x_" submit parameters use correct separator.

=== Release Notes ===
==== New features ====

When requesting `account_info` for the open ledger, include the `queue :
true` to get extra information about any queued transactions for this
account. (RIPD-1205).

==== Bug fixes ====

When using sign-and-submit mode to autofill a transaction's sequence
number, the logic will not reuse a sequence number that is in the queue
for this account. (RIPD-1206).

Labels for experimental "x_queue_okay" and "x_assume_tx" parameters to
`sign` and `submit` updated to use correct separator.
This commit is contained in:
Edward Hennis
2016-06-29 19:37:19 -04:00
parent 348e65074e
commit e762d09e7e
10 changed files with 714 additions and 37 deletions

View File

@@ -356,9 +356,11 @@ TxQ::eraseAndAdvance(TxQ::FeeMultiSet::const_iterator_type candidateIter)
the latter case, continue through the fee queue anyway
to head off potential ordering manipulation problems.
*/
auto feeNextIter = std::next(candidateIter);
bool useAccountNext = accountNextIter != txQAccount.transactions.end() &&
accountNextIter->first == candidateIter->sequence + 1 &&
accountNextIter->second.feeLevel > candidateIter->feeLevel;
(feeNextIter == byFee_.end() ||
accountNextIter->second.feeLevel > feeNextIter->feeLevel);
auto candidateNextIter = byFee_.erase(candidateIter);
txQAccount.transactions.erase(accountIter);
return useAccountNext ?
@@ -917,7 +919,7 @@ TxQ::apply(Application& app, OpenView& view,
*/
void
TxQ::processValidatedLedger(Application& app,
TxQ::processClosedLedger(Application& app,
OpenView const& view, bool timeLeap)
{
auto const allowEscalation =
@@ -1145,6 +1147,38 @@ TxQ::getMetrics(Config const& config, OpenView const& view,
return result;
}
auto
TxQ::getAccountTxs(AccountID const& account, Config const& config,
ReadView const& view) const
-> boost::optional<std::map<TxSeq, AccountTxDetails>>
{
auto const allowEscalation =
(view.rules().enabled(featureFeeEscalation,
config.features));
if (!allowEscalation)
return boost::none;
std::lock_guard<std::mutex> lock(mutex_);
auto accountIter = byAccount_.find(account);
if (accountIter == byAccount_.end() ||
accountIter->second.transactions.empty())
return boost::none;
std::map<TxSeq, AccountTxDetails> result;
for (auto const& tx : accountIter->second.transactions)
{
auto& resultTx = result[tx.first];
resultTx.feeLevel = tx.second.feeLevel;
if(tx.second.lastValid)
resultTx.lastValid.emplace(*tx.second.lastValid);
if(tx.second.consequences)
resultTx.consequences.emplace(*tx.second.consequences);
}
return result;
}
Json::Value
TxQ::doRPC(Application& app) const
{