• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ sle::pointer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: sleRippleState

static
std::uint32_t
rippleQuality (
    LedgerEntrySet& ledger,
    AccountID const& destination,
    AccountID const& source,
    Currency const& currency,
    SField const& sfLow,
    SField const& sfHigh)
{
    std::uint32_t uQuality (QUALITY_ONE);

    if (destination != source)
    {
        SLE::pointer sleRippleState (ledger.entryCache (ltRIPPLE_STATE,
            getRippleStateIndex (destination, source, currency)));

        // we should be able to assert(sleRippleState) here

        if (sleRippleState)
        {
            auto const& sfField = destination < source ? sfLow : sfHigh;

            uQuality = sleRippleState->isFieldPresent (sfField)
                ? sleRippleState->getFieldU32 (sfField)
                : QUALITY_ONE;

            if (!uQuality)
                uQuality = 1; // Avoid divide by zero.
        }
    }

    return uQuality;
}
开发者ID:reecer,项目名称:rippled,代码行数:34,代码来源:RippleLiquidity.cpp


示例2: applyFeature

TER ChangeTransactor::applyFeature ()
{
    uint256 feature = mTxn.getFieldH256 (sfFeature);

    SLE::pointer featureObject = mEngine->entryCache (ltFEATURES, Ledger::getLedgerFeatureIndex ());

    if (!featureObject)
        featureObject = mEngine->entryCreate (ltFEATURES, Ledger::getLedgerFeatureIndex ());

    STVector256 features = featureObject->getFieldV256 (sfFeatures);

    if (features.hasValue (feature))
        return tefALREADY;

    features.addValue (feature);
    featureObject->setFieldV256 (sfFeatures, features);
    mEngine->entryModify (featureObject);

    getApp().getFeatureTable ().enableFeature (feature);

    if (!getApp().getFeatureTable ().isFeatureSupported (feature))
        getApp().getOPs ().setFeatureBlocked ();

    return tesSUCCESS;
}
开发者ID:12w21,项目名称:rippled,代码行数:25,代码来源:ChangeTransactor.cpp


示例3: checkNoRipple

/** Check if a sequence of three accounts violates the no ripple constrains
    [first] -> [second] -> [third]
    Disallowed if 'second' set no ripple on [first]->[second] and
    [second]->[third]
*/
TER PathState::checkNoRipple (
    AccountID const& firstAccount,
    AccountID const& secondAccount,
    // This is the account whose constraints we are checking
    AccountID const& thirdAccount,
    Currency const& currency)
{
    // fetch the ripple lines into and out of this node
    SLE::pointer sleIn = view().peek (
        keylet::line(firstAccount, secondAccount, currency));
    SLE::pointer sleOut = view().peek (
        keylet::line(secondAccount, thirdAccount, currency));

    if (!sleIn || !sleOut)
    {
        terStatus = terNO_LINE;
    }
    else if (
        sleIn->getFieldU32 (sfFlags) &
            ((secondAccount > firstAccount) ? lsfHighNoRipple : lsfLowNoRipple) &&
        sleOut->getFieldU32 (sfFlags) &
            ((secondAccount > thirdAccount) ? lsfHighNoRipple : lsfLowNoRipple))
    {
        JLOG (j_.info)
            << "Path violates noRipple constraint between "
            << firstAccount << ", "
            << secondAccount << " and "
            << thirdAccount;

        terStatus = terNO_RIPPLE;
    }
    return terStatus;
}
开发者ID:alexandrev,项目名称:rippled,代码行数:38,代码来源:PathState.cpp


示例4: getMasterGenerator

// Look up the master public generator for a regular seed so we may index source accounts ids.
// --> naRegularSeed
// <-- naMasterGenerator
Json::Value getMasterGenerator (
    Ledger::ref lrLedger, const RippleAddress& naRegularSeed,
    RippleAddress& naMasterGenerator, NetworkOPs& netOps)
{
    RippleAddress       na0Public;      // To find the generator's index.
    RippleAddress       na0Private;     // To decrypt the master generator's cipher.
    RippleAddress       naGenerator = RippleAddress::createGeneratorPublic (naRegularSeed);

    na0Public.setAccountPublic (naGenerator, 0);
    na0Private.setAccountPrivate (naGenerator, naRegularSeed, 0);

    SLE::pointer        sleGen          = netOps.getGenerator (lrLedger, na0Public.getAccountID ());

    if (!sleGen)
    {
        // No account has been claimed or has had it password set for seed.
        return rpcError (rpcNO_ACCOUNT);
    }

    Blob    vucCipher           = sleGen->getFieldVL (sfGenerator);
    Blob    vucMasterGenerator  = na0Private.accountPrivateDecrypt (na0Public, vucCipher);

    if (vucMasterGenerator.empty ())
    {
        return rpcError (rpcFAIL_GEN_DECRYPT);
    }

    naMasterGenerator.setGenerator (vucMasterGenerator);

    return Json::Value (Json::objectValue);
}
开发者ID:Cocongo,项目名称:rippled,代码行数:34,代码来源:GetMasterGenerator.cpp


示例5: view

TER
SetSignerList::removeSignersFromLedger (Keylet const& accountKeylet,
        Keylet const& ownerDirKeylet, Keylet const& signerListKeylet)
{
    // We have to examine the current SignerList so we know how much to
    // reduce the OwnerCount.
    SLE::pointer signers = view().peek (signerListKeylet);

    // If the signer list doesn't exist we've already succeeded in deleting it.
    if (!signers)
        return tesSUCCESS;

    STArray const& actualList = signers->getFieldArray (sfSignerEntries);
    int const removeFromOwnerCount = ownerCountDelta (actualList.size()) * -1;

    // Remove the node from the account directory.
    auto const hint = (*signers)[sfOwnerNode];

    auto viewJ = ctx_.app.journal ("View");
    TER const result  = dirDelete(ctx_.view(), false, hint,
        ownerDirKeylet.key, signerListKeylet.key, false, (hint == 0), viewJ);

    if (result == tesSUCCESS)
        adjustOwnerCount(view(),
            view().peek(accountKeylet), removeFromOwnerCount, viewJ);

    ctx_.view().erase (signers);

    return result;
}
开发者ID:E-LLP,项目名称:rippled,代码行数:30,代码来源:SetSignerList.cpp


示例6: applyAmendment

TER Change::applyAmendment ()
{
    uint256 amendment (mTxn.getFieldH256 (sfAmendment));

    SLE::pointer amendmentObject (mEngine->entryCache (
        ltAMENDMENTS, Ledger::getLedgerAmendmentIndex ()));

    if (!amendmentObject)
    {
        amendmentObject = mEngine->entryCreate(
            ltAMENDMENTS, Ledger::getLedgerAmendmentIndex());
    }

    STVector256 amendments (amendmentObject->getFieldV256 (sfAmendments));

    if (amendments.hasValue (amendment))
        return tefALREADY;

    amendments.addValue (amendment);
    amendmentObject->setFieldV256 (sfAmendments, amendments);
    mEngine->entryModify (amendmentObject);

    getApp().getAmendmentTable ().enable (amendment);

    if (!getApp().getAmendmentTable ().isSupported (amendment))
        getApp().getOPs ().setAmendmentBlocked ();

    return tesSUCCESS;
}
开发者ID:CCJY,项目名称:rippled,代码行数:29,代码来源:Change.cpp


示例7: checkNoRipple

/** Check if a sequence of three accounts violates the no ripple constrains
    [first] -> [second] -> [third]
    Disallowed if 'second' set no ripple on [first]->[second] and [second]->[third]
*/
void PathState::checkNoRipple (
    uint160 const& firstAccount,
    uint160 const& secondAccount,  // This is the account whose constraints we are checking
    uint160 const& thirdAccount,
    uint160 const& currency)
{
    // fetch the ripple lines into and out of this node
    SLE::pointer sleIn = lesEntries.entryCache (ltRIPPLE_STATE,
        Ledger::getRippleStateIndex (firstAccount, secondAccount, currency));
    SLE::pointer sleOut = lesEntries.entryCache (ltRIPPLE_STATE,
        Ledger::getRippleStateIndex (secondAccount, thirdAccount, currency));

    if (!sleIn || !sleOut)
    {
        terStatus = terNO_LINE;
    }
    else if (
        is_bit_set (sleIn->getFieldU32 (sfFlags),
            (secondAccount > firstAccount) ? lsfHighNoRipple : lsfLowNoRipple) &&
        is_bit_set (sleOut->getFieldU32 (sfFlags),
            (secondAccount > thirdAccount) ? lsfHighNoRipple : lsfLowNoRipple))
    {
        WriteLog (lsINFO, RippleCalc) << "Path violates noRipple constraint between " <<
            RippleAddress::createHumanAccountID (firstAccount) << ", " <<
            RippleAddress::createHumanAccountID (secondAccount) << " and " <<
            RippleAddress::createHumanAccountID (thirdAccount);

        terStatus = terNO_RIPPLE;
    }
}
开发者ID:Payshare,项目名称:stellard,代码行数:34,代码来源:PathState.cpp


示例8: checkFreeze

/** Check if an expanded path violates freeze rules */
void PathState::checkFreeze()
{
    assert (nodes_.size() >= 2);

    // A path with no intermediaries -- pure issue/redeem
    // cannot be frozen.
    if (nodes_.size() == 2)
        return;

    SLE::pointer sle;

    for (std::size_t i = 0; i < (nodes_.size() - 1); ++i)
    {
        // Check each order book for a global freeze
        if (nodes_[i].uFlags & STPathElement::typeIssuer)
        {
            sle = view().peek (keylet::account(nodes_[i].issue_.account));

            if (sle && sle->isFlag (lsfGlobalFreeze))
            {
                terStatus = terNO_LINE;
                return;
            }
        }

        // Check each account change to make sure funds can leave
        if (nodes_[i].uFlags & STPathElement::typeAccount)
        {
            Currency const& currencyID = nodes_[i].issue_.currency;
            AccountID const& inAccount = nodes_[i].account_;
            AccountID const& outAccount = nodes_[i+1].account_;

            if (inAccount != outAccount)
            {
                sle = view().peek (keylet::account(outAccount));

                if (sle && sle->isFlag (lsfGlobalFreeze))
                {
                    terStatus = terNO_LINE;
                    return;
                }

                sle = view().peek (keylet::line(inAccount,
                        outAccount, currencyID));

                if (sle && sle->isFlag (
                    (outAccount > inAccount) ? lsfHighFreeze : lsfLowFreeze))
                {
                    terStatus = terNO_LINE;
                    return;
                }
            }
        }
    }
}
开发者ID:alexandrev,项目名称:rippled,代码行数:56,代码来源:PathState.cpp


示例9: assert

ter
createoffer::checkacceptasset(issueref issue) const
{
    /* only valid for custom currencies */
    assert (!isxrp (issue.currency));
    assert (!isvbc (issue.currency));

    sle::pointer const issueraccount = mengine->entrycache (
        ltaccount_root, getaccountrootindex (issue.account));

    if (!issueraccount)
    {
        if (m_journal.warning) m_journal.warning <<
            "delay: can't receive ious from non-existent issuer: " <<
            to_string (issue.account);

        return (mparams & tapretry)
            ? terno_account
            : tecno_issuer;
    }

    if (issueraccount->getfieldu32 (sfflags) & lsfrequireauth)
    {
        sle::pointer const trustline (mengine->entrycache (
            ltripple_state, getripplestateindex (
                mtxnaccountid, issue.account, issue.currency)));

        if (!trustline)
        {
            return (mparams & tapretry)
                ? terno_line
                : tecno_line;
        }

        // entries have a canonical representation, determined by a
        // lexicographical "greater than" comparison employing strict weak
        // ordering. determine which entry we need to access.
        bool const canonical_gt (mtxnaccountid > issue.account);

        bool const is_authorized (trustline->getfieldu32 (sfflags) &
            (canonical_gt ? lsflowauth : lsfhighauth));

        if (!is_authorized)
        {
            if (m_journal.debug) m_journal.debug <<
                "delay: can't receive ious from issuer without auth.";

            return (mparams & tapretry)
                ? terno_auth
                : tecno_auth;
        }
    }

    return tessuccess;
}
开发者ID:moorecoin,项目名称:MooreCoinService,代码行数:55,代码来源:CreateOffer.cpp


示例10: canonical_gt

TER
CreateOffer::checkAcceptAsset(IssueRef issue) const
{
    /* Only valid for custom currencies */
    assert (!isXRP (issue.currency));

    SLE::pointer const issuerAccount = mEngine->entryCache (
        ltACCOUNT_ROOT, Ledger::getAccountRootIndex (issue.account));

    if (!issuerAccount)
    {
        if (m_journal.warning) m_journal.warning <<
            "delay: can't receive IOUs from non-existent issuer: " <<
            to_string (issue.account);

        return (mParams & tapRETRY)
            ? terNO_ACCOUNT
            : tecNO_ISSUER;
    }

    if (issuerAccount->getFieldU32 (sfFlags) & lsfRequireAuth)
    {
        SLE::pointer const trustLine (mEngine->entryCache (
            ltRIPPLE_STATE, Ledger::getRippleStateIndex (
                mTxnAccountID, issue.account, issue.currency)));

        if (!trustLine)
        {
            return (mParams & tapRETRY)
                ? terNO_LINE
                : tecNO_LINE;
        }

        // Entries have a canonical representation, determined by a
        // lexicographical "greater than" comparison employing strict weak
        // ordering. Determine which entry we need to access.
        bool const canonical_gt (mTxnAccountID > issue.account);

        bool const is_authorized (trustLine->getFieldU32 (sfFlags) &
            (canonical_gt ? lsfLowAuth : lsfHighAuth));

        if (!is_authorized)
        {
            if (m_journal.debug) m_journal.debug <<
                "delay: can't receive IOUs from issuer without auth.";

            return (mParams & tapRETRY)
                ? terNO_AUTH
                : tecNO_AUTH;
        }
    }

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


示例11: fillItems

void AccountItems::fillItems (const uint160& accountID, Ledger::ref ledger)
{
    uint256 const rootIndex = Ledger::getOwnerDirIndex (accountID);
    uint256 currentIndex    = rootIndex;

    // VFALCO TODO Rewrite all infinite loops to have clear terminating
    //             conditions defined in one location.
    //
    while (1)
    {
        SLE::pointer ownerDir   = ledger->getDirNode (currentIndex);

        // VFALCO TODO Rewrite to not return from the middle of the function
        if (!ownerDir)
            return;

        BOOST_FOREACH (uint256 const & uNode, ownerDir->getFieldV256 (sfIndexes).peekValue ())
        {
            // VFALCO TODO rename getSLEi() to something legible.
            SLE::pointer sleCur = ledger->getSLEi (uNode);

            if (!sleCur)
            {
                // item in directory not in ledger
            }
            else
            {
                AccountItem::pointer item = mOfType->makeItem (accountID, sleCur);

                // VFALCO NOTE Under what conditions would makeItem() return nullptr?
                // DJS NOTE If the item wasn't one this particular AccountItems was interested in
                // (For example, if the owner is only interested in ripple lines and this is an offer)
                if (item)
                {
                    mItems.push_back (item);
                }
            }
        }

        std::uint64_t uNodeNext    = ownerDir->getFieldU64 (sfIndexNext);

        // VFALCO TODO Rewrite to not return from the middle of the function
        if (!uNodeNext)
            return;

        currentIndex = Ledger::getDirNodeIndex (rootIndex, uNodeNext);
    }
}
开发者ID:BattleProgrammer,项目名称:stellard,代码行数:48,代码来源:AccountItems.cpp


示例12: removeSignersFromLedger

TER
SetSignerList::destroySignerList ()
{
    auto const accountKeylet = keylet::account (account_);
    // Destroying the signer list is only allowed if either the master key
    // is enabled or there is a regular key.
    SLE::pointer ledgerEntry = view().peek (accountKeylet);
    if ((ledgerEntry->isFlag (lsfDisableMaster)) &&
        (!ledgerEntry->isFieldPresent (sfRegularKey)))
            return tecNO_ALTERNATIVE_KEY;

    auto const ownerDirKeylet = keylet::ownerDir (account_);
    auto const signerListKeylet = keylet::signers (account_);
    return removeSignersFromLedger(
        accountKeylet, ownerDirKeylet, signerListKeylet);
}
开发者ID:E-LLP,项目名称:rippled,代码行数:16,代码来源:SetSignerList.cpp


示例13: applyFee

TER Change::applyFee ()
{

    SLE::pointer feeObject = mEngine->entryCache (
        ltFEE_SETTINGS, Ledger::getLedgerFeeIndex ());

    if (!feeObject)
        feeObject = mEngine->entryCreate (
            ltFEE_SETTINGS, Ledger::getLedgerFeeIndex ());

    m_journal.trace << 
        "Previous fee object: " << feeObject->getJson (0);

    feeObject->setFieldU64 (
        sfBaseFee, mTxn.getFieldU64 (sfBaseFee));
    feeObject->setFieldU32 (
        sfReferenceFeeUnits, mTxn.getFieldU32 (sfReferenceFeeUnits));
    feeObject->setFieldU32 (
        sfReserveBase, mTxn.getFieldU32 (sfReserveBase));
    feeObject->setFieldU32 (
        sfReserveIncrement, mTxn.getFieldU32 (sfReserveIncrement));

    mEngine->entryModify (feeObject);

    m_journal.trace << 
        "New fee object: " << feeObject->getJson (0);
    m_journal.warning << "Fees have been changed";
    return tesSUCCESS;
}
开发者ID:CCJY,项目名称:rippled,代码行数:29,代码来源:Change.cpp


示例14: fillItems

void AccountItems::fillItems (Account const& accountID, Ledger::ref ledger)
{
    uint256 const rootIndex = Ledger::getOwnerDirIndex (accountID);
    uint256 currentIndex    = rootIndex;

    // VFALCO TODO Rewrite all infinite loops to have clear terminating
    //             conditions defined in one location.
    //
    while (1)
    {
        SLE::pointer ownerDir   = ledger->getDirNode (currentIndex);

        // VFALCO TODO Rewrite to not return from the middle of the function
        if (!ownerDir)
            return;

        for (auto const& uNode: ownerDir->getFieldV256 (sfIndexes).peekValue ())
        {
            // VFALCO TODO rename getSLEi() to something legible.
            SLE::pointer sleCur = ledger->getSLEi (uNode);

            if (sleCur)
            {
                // The item in the directory is in ledger
                auto item = mOfType->makeItem (accountID, sleCur);

                // makeItem() returns nullptr if the item wasn't one this
                // particular AccountItems was interested in - for example, if
                // the owner is only interested in ripple lines and this is an
                // offer.
                if (item)
                    mItems.push_back (item);
            }
        }

        std::uint64_t uNodeNext    = ownerDir->getFieldU64 (sfIndexNext);

        if (!uNodeNext)
            return;

        currentIndex = Ledger::getDirNodeIndex (rootIndex, uNodeNext);
    }
}
开发者ID:RagnarDanneskjold,项目名称:rippled,代码行数:43,代码来源:AccountItems.cpp


示例15: checkFreeze

/** Check if an expanded path violates freeze rules */
void PathState::checkFreeze()
{
    assert(vpnNodes.size() >= 2);
    
    // A path with no intermediaries -- pure issue/redeem
    // cannot be frozen.
    if(vpnNodes.size() == 2)
        return;
       
    for(std::size_t i = 0; i < (vpnNodes.size() - 1); ++i)
    {  
        // Check each account change to make sure funds can leave
        if(vpnNodes[i].uFlags & STPathElement::typeAccount)
        {
            uint160 const& currencyID = vpnNodes[i].uCurrencyID;
            uint160 const& inAccount = vpnNodes[i].uAccountID;
       
            uint160 const& issuingAccount = vpnNodes[i+1].uAccountID;
            
            if(inAccount != issuingAccount)
            {
                SLE::pointer sle = lesEntries.entryCache(ltACCOUNT_ROOT,
                    Ledger::getAccountRootIndex(issuingAccount));
                
                if(sle && sle->isFlag(lsfRequireAuth))
                {
                    sle = lesEntries.entryCache(ltRIPPLE_STATE,
                        Ledger::getRippleStateIndex(inAccount,
                        issuingAccount, currencyID));
                
                    if(sle && !sle->isFlag(
                        (issuingAccount > inAccount) ? lsfHighAuth : lsfLowAuth))
                    {
                        terStatus = terNO_LINE;
                        return;
                    }
                    
                }
            }
        }
    }
}
开发者ID:Payshare,项目名称:stellard,代码行数:43,代码来源:PathState.cpp


示例16: toLedger

void
SetSignerList::writeSignersToSLE (SLE::pointer const& ledgerEntry) const
{
    // Assign the quorum.
    ledgerEntry->setFieldU32 (sfSignerQuorum, quorum_);

    // For now, assign the default SignerListID.
    ledgerEntry->setFieldU32 (sfSignerListID, defaultSignerListID_);

    // Create the SignerListArray one SignerEntry at a time.
    STArray toLedger (signers_.size ());
    for (auto const& entry : signers_)
    {
        toLedger.emplace_back(sfSignerEntry);
        STObject& obj = toLedger.back();
        obj.reserve (2);
        obj.setAccountID (sfAccount, entry.account);
        obj.setFieldU16 (sfSignerWeight, entry.weight);
    }

    // Assign the SignerEntries.
    ledgerEntry->setFieldArray (sfSignerEntries, toLedger);
}
开发者ID:E-LLP,项目名称:rippled,代码行数:23,代码来源:SetSignerList.cpp


示例17: view

TER
CancelTicket::doApply ()
{
    uint256 const ticketId = ctx_.tx.getFieldH256 (sfTicketID);

    // VFALCO This is highly suspicious, we're requiring that the
    //        transaction provide the return value of getTicketIndex?
    SLE::pointer sleTicket = view().peek (keylet::ticket(ticketId));

    if (!sleTicket)
        return tecNO_ENTRY;

    auto const ticket_owner =
        sleTicket->getAccountID (sfAccount);

    bool authorized =
        account_ == ticket_owner;

    // The target can also always remove a ticket
    if (!authorized && sleTicket->isFieldPresent (sfTarget))
        authorized = (account_ == sleTicket->getAccountID (sfTarget));

    // And finally, anyone can remove an expired ticket
    if (!authorized && sleTicket->isFieldPresent (sfExpiration))
    {
        using tp = NetClock::time_point;
        using d = tp::duration;
        auto const expiration = tp{d{sleTicket->getFieldU32(sfExpiration)}};

        if (view().parentCloseTime() >= expiration)
            authorized = true;
    }

    if (!authorized)
        return tecNO_PERMISSION;

    std::uint64_t const hint (sleTicket->getFieldU64 (sfOwnerNode));

    if (! ctx_.view().dirRemove(
            keylet::ownerDir(ticket_owner), hint, ticketId, false))
    {
        return tefBAD_LEDGER;
    }

    auto viewJ = ctx_.app.journal ("View");
    adjustOwnerCount(view(), view().peek(
        keylet::account(ticket_owner)), -1, viewJ);
    ctx_.view ().erase (sleTicket);

    return tesSUCCESS;
}
开发者ID:Empresaria,项目名称:rippled,代码行数:51,代码来源:CancelTicket.cpp


示例18: makeEntry

    LedgerEntry::pointer LedgerEntry::makeEntry(SLE::pointer sle)
    {
        switch (sle->getType())
        {
        case ltACCOUNT_ROOT:
            return LedgerEntry::pointer(new AccountEntry(sle));

        case ltRIPPLE_STATE:
            return LedgerEntry::pointer(new TrustLine(sle));

        case ltOFFER:
            return LedgerEntry::pointer(new OfferEntry(sle));

        case ltOWNERSHIP:
            return LedgerEntry::pointer(new Ownership(sle));

        case ltOBJECT_DESC:
            return LedgerEntry::pointer(new ObjectInfo(sle));

        }
        return(LedgerEntry::pointer());
    }
开发者ID:naumenkogs,项目名称:blockverify-core,代码行数:22,代码来源:LedgerEntry.cpp


示例19: doApply

    TER doApply () override
    {
        assert (mTxnAccount);

        uint256 const ticketId = mTxn.getFieldH256 (sfTicketID);

        SLE::pointer sleTicket = mEngine->view ().entryCache (ltTICKET, ticketId);

        if (!sleTicket)
            return tecNO_ENTRY;

        Account const ticket_owner (sleTicket->getFieldAccount160 (sfAccount));

        bool authorized (mTxnAccountID == ticket_owner);

        // The target can also always remove a ticket
        if (!authorized && sleTicket->isFieldPresent (sfTarget))
            authorized = (mTxnAccountID == sleTicket->getFieldAccount160 (sfTarget));

        // And finally, anyone can remove an expired ticket
        if (!authorized && sleTicket->isFieldPresent (sfExpiration))
        {
            std::uint32_t const expiration = sleTicket->getFieldU32 (sfExpiration);

            if (mEngine->getLedger ()->getParentCloseTimeNC () >= expiration)
                authorized = true;
        }

        if (!authorized)
            return tecNO_PERMISSION;

        std::uint64_t const hint (sleTicket->getFieldU64 (sfOwnerNode));

        TER const result = mEngine->view ().dirDelete (false, hint,
            getOwnerDirIndex (ticket_owner), ticketId, false, (hint == 0));

        mEngine->view ().decrementOwnerCount (mTxnAccount);
        mEngine->view ().entryDelete (sleTicket);

        return result;
    }
开发者ID:BobWay,项目名称:rippled,代码行数:41,代码来源:CancelTicket.cpp


示例20: bPassive

TER
CreateOffer::doApply ()
{
    if (m_journal.debug) m_journal.debug <<
        "OfferCreate> " << mTxn.getJson (0);

    std::uint32_t const uTxFlags = mTxn.getFlags ();

    bool const bPassive (uTxFlags & tfPassive);
    bool const bImmediateOrCancel (uTxFlags & tfImmediateOrCancel);
    bool const bFillOrKill (uTxFlags & tfFillOrKill);
    bool const bSell  (uTxFlags & tfSell);

    STAmount saTakerPays = mTxn.getFieldAmount (sfTakerPays);
    STAmount saTakerGets = mTxn.getFieldAmount (sfTakerGets);

    if (!saTakerPays.isLegalNet () || !saTakerGets.isLegalNet ())
        return temBAD_AMOUNT;

    auto const& uPaysIssuerID = saTakerPays.getIssuer ();
    auto const& uPaysCurrency = saTakerPays.getCurrency ();

    auto const& uGetsIssuerID = saTakerGets.getIssuer ();
    auto const& uGetsCurrency = saTakerGets.getCurrency ();

    bool const bHaveExpiration (mTxn.isFieldPresent (sfExpiration));
    bool const bHaveCancel (mTxn.isFieldPresent (sfOfferSequence));

    std::uint32_t const uExpiration = mTxn.getFieldU32 (sfExpiration);
    std::uint32_t const uCancelSequence = mTxn.getFieldU32 (sfOfferSequence);

    // FIXME understand why we use SequenceNext instead of current transaction
    //       sequence to determine the transaction. Why is the offer seuqnce
    //       number insufficient?

    std::uint32_t const uAccountSequenceNext = mTxnAccount->getFieldU32 (sfSequence);
    std::uint32_t const uSequence = mTxn.getSequence ();

    const uint256 uLedgerIndex = Ledger::getOfferIndex (mTxnAccountID, uSequence);

    if (m_journal.debug)
    {
        m_journal.debug <<
            "Creating offer node: " << to_string (uLedgerIndex) <<
            " uSequence=" << uSequence;

        if (bImmediateOrCancel)
            m_journal.debug << "Transaction: IoC set.";

        if (bFillOrKill)
            m_journal.debug << "Transaction: FoK set.";
    }

    // This is the original rate of this offer, and is the rate at which it will
    // be placed, even if crossing offers change the amounts.
    std::uint64_t const uRate = STAmount::getRate (saTakerGets, saTakerPays);

    TER terResult (tesSUCCESS);

    // This is the ledger view that we work against. Transactions are applied
    // as we go on processing transactions.
    core::LedgerView& view (mEngine->view ());

    // This is a checkpoint with just the fees paid. If something goes wrong
    // with this transaction, we roll back to this ledger.
    core::LedgerView view_checkpoint (view);

    view.bumpSeq (); // Begin ledger variance.

    SLE::pointer sleCreator = mEngine->entryCache (
        ltACCOUNT_ROOT, Ledger::getAccountRootIndex (mTxnAccountID));

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

        terResult = temINVALID_FLAG;
    }
    else if (bImmediateOrCancel && bFillOrKill)
    {
        if (m_journal.debug) m_journal.debug <<
            "Malformed transaction: both IoC and FoK set.";

        terResult = temINVALID_FLAG;
    }
    else if (bHaveExpiration && !uExpiration)
    {
        m_journal.warning <<
            "Malformed offer: bad expiration";

        terResult = temBAD_EXPIRATION;
    }
    else if (saTakerPays.isNative () && saTakerGets.isNative ())
    {
        m_journal.warning <<
            "Malformed offer: XRP for XRP";

        terResult = temBAD_OFFER;
    }
//.........这里部分代码省略.........
开发者ID:CCJY,项目名称:rippled,代码行数:101,代码来源:CreateOffer.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ slic3r::ExPolygons类代码示例发布时间:2022-05-31
下一篇:
C++ sklayerrasterizer::Builder类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap