当前位置: 首页>>代码示例>>C++>>正文


C++ pointer::setFieldAccount方法代码示例

本文整理汇总了C++中sle::pointer::setFieldAccount方法的典型用法代码示例。如果您正苦于以下问题:C++ pointer::setFieldAccount方法的具体用法?C++ pointer::setFieldAccount怎么用?C++ pointer::setFieldAccount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sle::pointer的用法示例。


在下文中一共展示了pointer::setFieldAccount方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: doApply

    TER doApply () override
    {
        // Divvy if source or destination is non-native or if there are paths.
        std::uint32_t const uTxFlags = mTxn.getFlags ();
        bool const partialPaymentAllowed = uTxFlags & tfPartialPayment;
        bool const limitQuality = uTxFlags & tfLimitQuality;
        bool const defaultPathsAllowed = !(uTxFlags & tfNoDivvyDirect);
        bool const bPaths = mTxn.isFieldPresent (sfPaths);
        bool const bMax = mTxn.isFieldPresent (sfSendMax);
        AccountID const uDstAccountID (mTxn.getFieldAccount160 (sfDestination));
        STAmount const saDstAmount (mTxn.getFieldAmount (sfAmount));
        STAmount maxSourceAmount;
        if (bMax)
            maxSourceAmount = mTxn.getFieldAmount (sfSendMax);
        else if (saDstAmount.native ())
            maxSourceAmount = saDstAmount;
        else
          maxSourceAmount = STAmount (
              {saDstAmount.getCurrency (), mTxnAccountID},
              saDstAmount.mantissa(), saDstAmount.exponent (),
              saDstAmount < zero);

        m_journal.trace <<
            "maxSourceAmount=" << maxSourceAmount.getFullText () <<
            " saDstAmount=" << saDstAmount.getFullText ();

        // Open a ledger for editing.
        auto const index = getAccountRootIndex (uDstAccountID);
        SLE::pointer sleDst (mEngine->view().entryCache (ltACCOUNT_ROOT, index));

        if (!sleDst)
        {
            // Destination account does not exist.
            if (!saDstAmount.native ())
            {
                m_journal.trace <<
                    "Delay transaction: Destination account does not exist.";

                // Another transaction could create the account and then this
                // transaction would succeed.
                return tecNO_DST;
            }
            else if (mParams & tapOPEN_LEDGER && partialPaymentAllowed)
            {
                // You cannot fund an account with a partial payment.
                // Make retry work smaller, by rejecting this.
                m_journal.trace <<
                    "Delay transaction: Partial payment not allowed to create account.";


                // Another transaction could create the account and then this
                // transaction would succeed.
                return telNO_DST_PARTIAL;
            }
            else if (saDstAmount < STAmount (mEngine->getLedger ()->getReserve (0)))
            {
                // getReserve() is the minimum amount that an account can have.
                // Reserve is not scaled by load.
                m_journal.trace <<
                    "Delay transaction: Destination account does not exist. " <<
                    "Insufficent payment to create account.";

                // TODO: dedupe
                // Another transaction could create the account and then this
                // transaction would succeed.
                return tecNO_DST_INSUF_XDV;
            }

            // Create the account.
            sleDst = std::make_shared<SLE>(ltACCOUNT_ROOT,
                getAccountRootIndex (uDstAccountID));
            sleDst->setFieldAccount (sfAccount, uDstAccountID);
            sleDst->setFieldU32 (sfSequence, 1);
            mEngine->view().entryCreate(sleDst);
        }
        else if ((sleDst->getFlags () & lsfRequireDestTag) &&
                 !mTxn.isFieldPresent (sfDestinationTag))
        {
            // The tag is basically account-specific information we don't
            // understand, but we can require someone to fill it in.

            // We didn't make this test for a newly-formed account because there's
            // no way for this field to be set.
            m_journal.trace << "Malformed transaction: DestinationTag required.";

            return tecDST_TAG_NEEDED;
        }
        else
        {
            // Tell the engine that we are intending to change the the destination
            // account.  The source account gets always charged a fee so it's always
            // marked as modified.
            mEngine->view().entryModify (sleDst);
        }

        TER terResult;

        bool const bDivvy = bPaths || bMax || !saDstAmount.native ();
        // XXX Should bMax be sufficient to imply divvy?

//.........这里部分代码省略.........
开发者ID:xdv,项目名称:divvyd,代码行数:101,代码来源:Payment.cpp

示例2: doApply

    TER doApply () override
    {
        assert (mTxnAccount);

        // A ticket counts against the reserve of the issuing account, but we check
        // the starting balance because we want to allow dipping into the reserve to
        // pay fees.
        auto const accountReserve (mEngine->getLedger ()->getReserve (
            mTxnAccount->getFieldU32 (sfOwnerCount) + 1));

        if (mPriorBalance.getNValue () < accountReserve)
            return tecINSUFFICIENT_RESERVE;

        std::uint32_t expiration (0);

        if (mTxn.isFieldPresent (sfExpiration))
        {
            expiration = mTxn.getFieldU32 (sfExpiration);

            if (!expiration)
            {
                m_journal.warning <<
                    "Malformed ticket requestion: bad expiration";

                return temBAD_EXPIRATION;
            }

            if (mEngine->getLedger ()->getParentCloseTimeNC () >= expiration)
                return tesSUCCESS;
        }

        SLE::pointer sleTicket = mEngine->entryCreate (ltTICKET,
            Ledger::getTicketIndex (mTxnAccountID, mTxn.getSequence ()));

        sleTicket->setFieldAccount (sfAccount, mTxnAccountID);
        sleTicket->setFieldU32 (sfSequence, mTxn.getSequence ());

        if (expiration != 0)
            sleTicket->setFieldU32 (sfExpiration, expiration);

        if (mTxn.isFieldPresent (sfTarget))
        {
            Account const target_account (mTxn.getFieldAccount160 (sfTarget));

            SLE::pointer sleTarget = mEngine->entryCache (ltACCOUNT_ROOT,
                Ledger::getAccountRootIndex (target_account));

            // Destination account does not exist.
            if (!sleTarget)
                return tecNO_TARGET;

            // The issuing account is the default account to which the ticket
            // applies so don't bother saving it if that's what's specified.
            if (target_account != mTxnAccountID)
                sleTicket->setFieldAccount (sfTarget, target_account);
        }

        std::uint64_t hint;

        auto describer = [&](SLE::pointer p, bool b)
        {
            Ledger::ownerDirDescriber(p, b, mTxnAccountID);
        };
        TER result = mEngine->view ().dirAdd (
            hint,
            Ledger::getOwnerDirIndex (mTxnAccountID),
            sleTicket->getIndex (),
            describer);

        m_journal.trace <<
            "Creating ticket " << to_string (sleTicket->getIndex ()) <<
            ": " << transHuman (result);

        if (result != tesSUCCESS)
            return result;

        sleTicket->setFieldU64(sfOwnerNode, hint);

        // If we succeeded, the new entry counts agains the creator's reserve.
        mEngine->view ().incrementOwnerCount (mTxnAccount);

        return result;
    }
开发者ID:619213152,项目名称:vpal20,代码行数:83,代码来源:CreateTicket.cpp

示例3: bPassive


//.........这里部分代码省略.........

        std::uint64_t uOwnerNode;
        std::uint64_t uBookNode;
        uint256 uDirectory;

        // Add offer to owner's directory.
        terResult = view.dirAdd (uOwnerNode,
            Ledger::getOwnerDirIndex (mTxnAccountID), uLedgerIndex,
            std::bind (
                &Ledger::ownerDirDescriber, std::placeholders::_1,
                std::placeholders::_2, mTxnAccountID));

        if (tesSUCCESS == terResult)
        {
            // Update owner count.
            view.ownerCountAdjust (mTxnAccountID, 1, sleCreator);

            uint256 const uBookBase (Ledger::getBookBase (
                {{uPaysCurrency, uPaysIssuerID},
                    {uGetsCurrency, uGetsIssuerID}}));

            if (m_journal.debug) m_journal.debug <<
                "adding to book: " << to_string (uBookBase) <<
                " : " << saTakerPays.getHumanCurrency () <<
                "/" << to_string (saTakerPays.getIssuer ()) <<
                " -> " << saTakerGets.getHumanCurrency () <<
                "/" << to_string (saTakerGets.getIssuer ());

            // We use the original rate to place the offer.
            uDirectory = Ledger::getQualityIndex (uBookBase, uRate);

            // Add offer to order book.
            terResult = view.dirAdd (uBookNode, uDirectory, uLedgerIndex,
                std::bind (
                    &Ledger::qualityDirDescriber, std::placeholders::_1,
                    std::placeholders::_2, saTakerPays.getCurrency (),
                    uPaysIssuerID, saTakerGets.getCurrency (),
                    uGetsIssuerID, uRate));
        }

        if (tesSUCCESS == terResult)
        {
            if (m_journal.debug)
            {
                m_journal.debug <<
                    "sfAccount=" <<
                    to_string (mTxnAccountID);
                m_journal.debug <<
                    "uPaysIssuerID=" <<
                    to_string (uPaysIssuerID);
                m_journal.debug <<
                    "uGetsIssuerID=" <<
                    to_string (uGetsIssuerID);
                m_journal.debug <<
                    "saTakerPays.isNative()=" <<
                    saTakerPays.isNative ();
                m_journal.debug <<
                    "saTakerGets.isNative()=" <<
                    saTakerGets.isNative ();
                m_journal.debug <<
                    "uPaysCurrency=" <<
                    saTakerPays.getHumanCurrency ();
                m_journal.debug <<
                    "uGetsCurrency=" <<
                    saTakerGets.getHumanCurrency ();
            }

            SLE::pointer sleOffer (mEngine->entryCreate (ltOFFER, uLedgerIndex));

            sleOffer->setFieldAccount (sfAccount, mTxnAccountID);
            sleOffer->setFieldU32 (sfSequence, uSequence);
            sleOffer->setFieldH256 (sfBookDirectory, uDirectory);
            sleOffer->setFieldAmount (sfTakerPays, saTakerPays);
            sleOffer->setFieldAmount (sfTakerGets, saTakerGets);
            sleOffer->setFieldU64 (sfOwnerNode, uOwnerNode);
            sleOffer->setFieldU64 (sfBookNode, uBookNode);

            if (uExpiration)
                sleOffer->setFieldU32 (sfExpiration, uExpiration);

            if (bPassive)
                sleOffer->setFlag (lsfPassive);

            if (bSell)
                sleOffer->setFlag (lsfSell);

            if (m_journal.debug) m_journal.debug <<
                "final terResult=" << transToken (terResult) <<
                " sleOffer=" << sleOffer->getJson (0);
        }
    }

    if (terResult != tesSUCCESS)
    {
        m_journal.debug <<
            "final terResult=" << transToken (terResult);
    }

    return terResult;
}
开发者ID:CCJY,项目名称:rippled,代码行数:101,代码来源:CreateOffer.cpp

示例4: doApply

TER TransferTransactor::doApply ()
{
    WriteLog (lsTRACE, LedgerConsensus) << "Transfer transaction is applying\n\n\n\n\n\n";
    uint160 const uDstAccountID = mTxn.getFieldAccount160 (sfDestination);
    uint256 const objectId = mTxn.getObjectId ();
    WriteLog (lsTRACE, LedgerConsensus) << "Transfer transaction is applying";
    WriteLog (lsTRACE, LedgerConsensus) << "___________________________________applying";
    WriteLog (lsTRACE, LedgerConsensus) << "\n\n\n\n\n\n";


    WriteLog (lsTRACE, LedgerConsensus) << uDstAccountID;
    WriteLog (lsTRACE, LedgerConsensus) << objectId;


    if (!uDstAccountID)
    {
        m_journal.trace <<
            "Malformed transaction: Transfer destination account not specified.";

        return temDST_NEEDED;
    }
    WriteLog (lsTRACE, LedgerConsensus) << "Checking object in db \n\n\n\n\n\n";

    SLE::pointer sleObj (mEngine->entryCache (
        ltOWNERSHIP, objectId));
    WriteLog (lsTRACE, LedgerConsensus) << objectId << " \n\n\n\n\n\n";

    WriteLog (lsTRACE, LedgerConsensus) << "Checked object in db \n\n\n\n\n\n";
    WriteLog (lsTRACE, LedgerConsensus) << sleObj<< " \n\n\n\n\n\n";

    if (sleObj)
    {
        // Object  exists.
        WriteLog (lsTRACE, LedgerConsensus) << "Object  exists \n\n\n\n\n\n Source account";
        WriteLog (lsTRACE, LedgerConsensus) << mTxn.getSourceAccount().getAccountID();
        WriteLog (lsTRACE, LedgerConsensus) << "Object  exists \n\n\n\n\n\n New account";

        WriteLog (lsTRACE, LedgerConsensus) << uDstAccountID;


        if(sleObj->getFieldAccount160(sfAccount) != mTxn.getSourceAccount().getAccountID())
        {
            WriteLog (lsTRACE, LedgerConsensus) << "Not your object \n\n\n\n\n\n";
            return temMALFORMED;
        }

        SLE::pointer sleDst (mEngine->entryCache (
            ltACCOUNT_ROOT, Ledger::getAccountRootIndex (uDstAccountID)));

        if (!sleDst)
        {
            WriteLog (lsTRACE, LedgerConsensus) << "Destination account doesnt exist \n\n\n\n\n\n";
            return temMALFORMED;
        }



        sleObj->setFieldAccount (sfAccount, uDstAccountID);

        WriteLog (lsTRACE, LedgerConsensus) << "New dstAccount is set \n\n\n\n\n\n";

    }
    else
    {
        WriteLog (lsTRACE, LedgerConsensus) << "You cannot make Transfer to non-existing object \n\n\n\n\n\n";
        return temMALFORMED;
    }

    WriteLog (lsTRACE, LedgerConsensus) << "Transfer applying is finished \n\n\n\n\n\n";


    return tesSUCCESS;
}
开发者ID:naumenkogs,项目名称:blockverify-core,代码行数:73,代码来源:Transfer.cpp

示例5: doApply


//.........这里部分代码省略.........
                // Another transaction could create the account and then this
                // transaction would succeed.
                return tecNO_DST;
            }
            else if (mParams & tapOPEN_LEDGER && partialPaymentAllowed)
            {
                // You cannot fund an account with a partial payment.
                // Make retry work smaller, by rejecting this.
                m_journal.trace <<
                    "Delay transaction: Partial payment not allowed to create account.";


                // Another transaction could create the account and then this
                // transaction would succeed.
                return telNO_DST_PARTIAL;
            }
            else if (saDstAmount.getNValue () < mEngine->getLedger ()->getReserve (0))
            {
                // getReserve() is the minimum amount that an account can have.
                // Reserve is not scaled by load.
                m_journal.trace <<
                    "Delay transaction: Destination account does not exist. " <<
                    "Insufficent payment to create account.";

                // TODO: dedupe
                // Another transaction could create the account and then this
                // transaction would succeed.
                return tecNO_DST_INSUF_XRP;
            }

            // Create the account.
            auto const newIndex = getAccountRootIndex (uDstAccountID);
            sleDst = mEngine->entryCreate (ltACCOUNT_ROOT, newIndex);
            sleDst->setFieldAccount (sfAccount, uDstAccountID);
            sleDst->setFieldU32 (sfSequence, 1);
        }
        else if ((sleDst->getFlags () & lsfRequireDestTag) &&
                 !mTxn.isFieldPresent (sfDestinationTag))
        {
            // The tag is basically account-specific information we don't
            // understand, but we can require someone to fill it in.

            // We didn't make this test for a newly-formed account because there's
            // no way for this field to be set.
            m_journal.trace << "Malformed transaction: DestinationTag required.";

            return tefDST_TAG_NEEDED;
        }
        else
        {
            // Tell the engine that we are intending to change the the destination
            // account.  The source account gets always charged a fee so it's always
            // marked as modified.
            mEngine->entryModify (sleDst);
        }

        TER terResult;

        bool const bRipple = bPaths || bMax || !saDstAmount.isNative ();
        // XXX Should bMax be sufficient to imply ripple?

        if (bRipple)
        {
            // Ripple payment with at least one intermediate step and uses
            // transitive balances.
开发者ID:BobWay,项目名称:rippled,代码行数:66,代码来源:Payment.cpp

示例6: doApply


//.........这里部分代码省略.........

    SLE::pointer sleDst (mEngine->entryCache (
        ltACCOUNT_ROOT, Ledger::getAccountRootIndex (uDstAccountID)));

    if (!sleDst)
    {
        // Destination account does not exist.

        if (!saDstAmount.isNative ())
        {
            m_journal.trace <<
                "Delay transaction: Destination account does not exist.";

            // Another transaction could create the account and then this transaction would succeed.
            return tecNO_DST;
        }
        
        // Note: Reserve is not scaled by load.
        else if (saDstAmount.getNValue () < mEngine->getLedger ()->getReserve (0))
        {
            m_journal.trace <<
                "Delay transaction: Destination account does not exist. " <<
                "Insufficient payment to create account.";

            // Another transaction could create the account and then this
            // transaction would succeed.
            return tecNO_DST_INSUF_STR;
        }

        // Create the account.
        sleDst = mEngine->entryCreate (
            ltACCOUNT_ROOT, Ledger::getAccountRootIndex (uDstAccountID));

        sleDst->setFieldAccount (sfAccount, uDstAccountID);
        sleDst->setFieldU32 (sfSequence, 1);
    }
    else if ((sleDst->getFlags () & lsfRequireDestTag) && !mTxn.isFieldPresent (sfDestinationTag))
    {
        m_journal.trace <<
            "Malformed transaction: DestinationTag required.";

        return tefDST_TAG_NEEDED;
    }
    else
    {
        mEngine->entryModify (sleDst);
    }

    TER terResult;
    // XXX Should bMax be sufficient to imply ripple?
    bool const bRipple = bPaths || bMax || !saDstAmount.isNative ();

    if (bRipple)
    {
        // Ripple payment

        STPathSet spsPaths = mTxn.getFieldPathSet (sfPaths);
        std::vector<PathState::pointer> vpsExpanded;
        STAmount saMaxAmountAct;
        STAmount saDstAmountAct;

        try
        {
            bool const openLedger = is_bit_set (mParams, tapOPEN_LEDGER);
			bool tooManyPaths = false;
			if (spsPaths.size() > MAX_NUM_PATHS) tooManyPaths = true;
开发者ID:StanChe,项目名称:stellar-mobile,代码行数:67,代码来源:Payment.cpp

示例7: doApply

TER WalletAddTransactor::doApply ()
{
    std::uint32_t const uTxFlags = mTxn.getFlags ();

    if (uTxFlags & tfUniversalMask)
    {
        m_journal.trace <<
            "Malformed transaction: Invalid flags set.";

        return temINVALID_FLAG;
    }

    Blob const vucPubKey    = mTxn.getFieldVL (sfPublicKey);
    Blob const vucSignature = mTxn.getFieldVL (sfSignature);

    uint160 const uAuthKeyID (mTxn.getFieldAccount160 (sfRegularKey));
    RippleAddress const naMasterPubKey (
        RippleAddress::createAccountPublic (vucPubKey));
    uint160 const uDstAccountID (naMasterPubKey.getAccountID ());

    // FIXME: This should be moved to the transaction's signature check logic and cached
	if (!naMasterPubKey.verifySignature(
        Serializer::getSHA512Half (uAuthKeyID.begin (), uAuthKeyID.size ()), 
        vucSignature))
    {
        m_journal.trace <<
            "Unauthorized: bad signature ";
        return tefBAD_ADD_AUTH;
    }

    SLE::pointer sleDst (mEngine->entryCache (
        ltACCOUNT_ROOT, Ledger::getAccountRootIndex (uDstAccountID)));

    if (sleDst)
    {
        m_journal.trace <<
            "account already created";
        return tefCREATED;
    }

    // Direct STR payment.

    STAmount saDstAmount = mTxn.getFieldAmount (sfAmount);
    STAmount saPaid = mTxn.getTransactionFee ();
    STAmount const saSrcBalance = mTxnAccount->getFieldAmount (sfBalance);
    std::uint32_t const uOwnerCount = mTxnAccount->getFieldU32 (sfOwnerCount);
    std::uint64_t const uReserve = mEngine->getLedger ()->getReserve (uOwnerCount);
    

    // Make sure have enough reserve to send. Allow final spend to use reserve
    // for fee.
    // Note: Reserve is not scaled by fee.
    if (saSrcBalance + saPaid < saDstAmount + uReserve)
    {
        // Vote no. However, transaction might succeed, if applied in a
        // different order.
        m_journal.trace <<
            "Delay transaction: Insufficient funds: %s / %s (%d)" <<
            saSrcBalance.getText () << " / " <<
            (saDstAmount + uReserve).getText () << " with reserve = " <<
            uReserve;
        return tecUNFUNDED_ADD;
    }

    // Deduct initial balance from source account.
    mTxnAccount->setFieldAmount (sfBalance, saSrcBalance - saDstAmount);

    // Create the account.
    sleDst  = mEngine->entryCreate (ltACCOUNT_ROOT,
        Ledger::getAccountRootIndex (uDstAccountID));

    sleDst->setFieldAccount (sfAccount, uDstAccountID);
    sleDst->setFieldU32 (sfSequence, 1);
    sleDst->setFieldAmount (sfBalance, saDstAmount);
    sleDst->setFieldAccount (sfRegularKey, uAuthKeyID);

    return tesSUCCESS;
}
开发者ID:BattleProgrammer,项目名称:stellard,代码行数:78,代码来源:AddWallet.cpp


注:本文中的sle::pointer::setFieldAccount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。