Inline calls to cachedRead:

Problem:
- There are only a few call sites to cachedRead, and all of them
  currently do more work than is required since we know the type in each
  case.

Solution:
- "Inline" the codepath to cachedRead, but do not check if the type is
  valid. In all such call sites, we know the keylet to read directly.

This fixes #2550
This commit is contained in:
Joe Loser
2018-11-01 20:20:49 -04:00
committed by Nik Bougalis
parent ad4bbd8dff
commit c587012e5c
3 changed files with 10 additions and 21 deletions

View File

@@ -374,8 +374,8 @@ transactionPreProcessImpl (
if (!verify && !tx_json.isMember (jss::Sequence))
return RPC::missing_field_error ("tx_json.Sequence");
std::shared_ptr<SLE const> sle = cachedRead(*ledger,
keylet::account(srcAddressID).key, ltACCOUNT_ROOT);
std::shared_ptr<SLE const> sle = ledger->read(
keylet::account(srcAddressID));
if (verify && !sle)
{
@@ -981,12 +981,11 @@ Json::Value transactionSignFor (
return preprocResult.first;
{
std::shared_ptr<SLE const> account_state = ledger->read(
keylet::account(*signerAccountID));
// Make sure the account and secret belong together.
auto const err = acctMatchesPubKey (
cachedRead(
*ledger,
keylet::account(*signerAccountID).key,
ltACCOUNT_ROOT),
account_state,
*signerAccountID,
multiSignPubKey);
@@ -1060,8 +1059,8 @@ Json::Value transactionSubmitMultiSigned (
auto const srcAddressID = txJsonResult.second;
std::shared_ptr<SLE const> sle = cachedRead(*ledger,
keylet::account(srcAddressID).key, ltACCOUNT_ROOT);
std::shared_ptr<SLE const> sle = ledger->read(
keylet::account(srcAddressID));
if (!sle)
{