Example #1
0
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;
}
Example #2
0
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;
}
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);
    }
}