mirror of
				https://github.com/Xahau/xahaud.git
				synced 2025-11-04 10:45:50 +00:00 
			
		
		
		
	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:
		@@ -410,17 +410,6 @@ std::pair<std::shared_ptr<
 | 
			
		||||
        STObject const>>
 | 
			
		||||
deserializeTxPlusMeta (SHAMapItem const& item);
 | 
			
		||||
 | 
			
		||||
// DEPRECATED
 | 
			
		||||
inline
 | 
			
		||||
std::shared_ptr<SLE const>
 | 
			
		||||
cachedRead (ReadView const& ledger, uint256 const& key,
 | 
			
		||||
    boost::optional<LedgerEntryType> type = boost::none)
 | 
			
		||||
{
 | 
			
		||||
    if (type)
 | 
			
		||||
        return ledger.read(Keylet(*type, key));
 | 
			
		||||
    return ledger.read(keylet::unchecked(key));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
} // ripple
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 
 | 
			
		||||
@@ -150,8 +150,9 @@ public:
 | 
			
		||||
                return true;
 | 
			
		||||
            if (view.txExists(txn.getID()))
 | 
			
		||||
                return true;
 | 
			
		||||
            auto const sle = cachedRead(view,
 | 
			
		||||
                keylet::account(txn.getAccount()).key, ltACCOUNT_ROOT);
 | 
			
		||||
 | 
			
		||||
            std::shared_ptr<SLE const> sle = view.read(
 | 
			
		||||
                 keylet::account(txn.getAccount()));
 | 
			
		||||
            if (! sle)
 | 
			
		||||
                return false;
 | 
			
		||||
            return sle->getFieldU32 (sfSequence) > txn.getSeq ();
 | 
			
		||||
 
 | 
			
		||||
@@ -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)
 | 
			
		||||
    {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user