Skip to content

Commit

Permalink
async submitTransaction
Browse files Browse the repository at this point in the history
  • Loading branch information
RichardAH committed Nov 16, 2024
1 parent 57a1329 commit ed8d31d
Showing 1 changed file with 56 additions and 50 deletions.
106 changes: 56 additions & 50 deletions src/ripple/app/misc/NetworkOPs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1136,73 +1136,79 @@ NetworkOPsImp::strOperatingMode(OperatingMode const mode, bool const admin)
void
NetworkOPsImp::submitTransaction(std::shared_ptr<STTx const> const& iTrans)
{
if (isNeedNetworkLedger())
{
// Nothing we can do if we've never been in sync
return;
}
// Launch async task and return immediately
std::async(std::launch::async, [this, iTrans]() {
if (isNeedNetworkLedger())
{
// Nothing we can do if we've never been in sync
return;
}

auto const view = m_ledgerMaster.getCurrentLedger();
auto const view = m_ledgerMaster.getCurrentLedger();

// Enforce Network bar for emitted txn
if (view->rules().enabled(featureHooks) && hook::isEmittedTxn(*iTrans))
{
// RH NOTE: Warning removed here due to ConsesusSet using this function
// which continually triggers this bar. Doesn't seem dangerous, just
// annoying.
// Enforce Network bar for emitted txn
if (view->rules().enabled(featureHooks) && hook::isEmittedTxn(*iTrans))
{
// RH NOTE: Warning removed here due to ConsesusSet using this function
// which continually triggers this bar. Doesn't seem dangerous, just
// annoying.

// JLOG(m_journal.warn())
// << "Submitted transaction invalid: EmitDetails present.";
return;
}
// JLOG(m_journal.warn())
// << "Submitted transaction invalid: EmitDetails present.";
return;
}

// this is an asynchronous interface
auto const trans = sterilize(*iTrans);
// this is an asynchronous interface
auto const trans = sterilize(*iTrans);

auto const txid = trans->getTransactionID();
auto const flags = app_.getHashRouter().getFlags(txid);
auto const txid = trans->getTransactionID();
auto const flags = app_.getHashRouter().getFlags(txid);

if ((flags & SF_BAD) != 0)
{
// RH NOTE: Warning removed here due to ConsesusSet using this function
// which continually triggers this bar. Doesn't seem dangerous, just
// annoying.
if ((flags & SF_BAD) != 0)
{
// RH NOTE: Warning removed here due to ConsesusSet using this function
// which continually triggers this bar. Doesn't seem dangerous, just
// annoying.

// JLOG(m_journal.warn()) << "Submitted transaction cached bad";
return;
}
// JLOG(m_journal.warn()) << "Submitted transaction cached bad";
return;
}

try
{
auto const [validity, reason] = checkValidity(
app_.getHashRouter(),
*trans,
m_ledgerMaster.getValidatedRules(),
app_.config());
try
{
auto const [validity, reason] = checkValidity(
app_.getHashRouter(),
*trans,
m_ledgerMaster.getValidatedRules(),
app_.config());

if (validity != Validity::Valid)
if (validity != Validity::Valid)
{
JLOG(m_journal.warn())
<< "Submitted transaction invalid: " << reason;
return;
}
}
catch (std::exception const& ex)
{
JLOG(m_journal.warn())
<< "Submitted transaction invalid: " << reason;
<< "Exception checking transaction " << txid << ": " << ex.what();

return;
}
}
catch (std::exception const& ex)
{
JLOG(m_journal.warn())
<< "Exception checking transaction " << txid << ": " << ex.what();

return;
}

std::string reason;
std::string reason;

auto tx = std::make_shared<Transaction>(trans, reason, app_);
auto tx = std::make_shared<Transaction>(trans, reason, app_);

m_job_queue.addJob(jtTRANSACTION, "submitTxn", [this, tx]() {
auto t = tx;
processTransaction(t, false, false, FailHard::no);
m_job_queue.addJob(jtTRANSACTION, "submitTxn", [this, tx]() {
auto t = tx;
processTransaction(t, false, false, FailHard::no);
});
});

// Return immediately while async task runs
return;
}

void
Expand Down

0 comments on commit ed8d31d

Please # to comment.