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


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

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


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

示例1: doApply

    TER doApply () override
    {
        Account const refereeID (mTxn.getFieldAccount160 (sfDestination));
        Account const referenceID (mTxnAccountID);

        if (!refereeID)
        {
            m_journal.warning <<
                "Malformed transaction: Referee account not specified.";

            return temDST_NEEDED;
        }
        else if (referenceID == refereeID)
        {
            // You're referring yourself.
            m_journal.trace <<
                "Malformed transaction: Redundant transaction:" <<
                " reference=" << to_string(referenceID) <<
                " referee=" << to_string(refereeID);

            return temREDUNDANT;
        }

        //
        // Open a ledger for editing.
        SLE::pointer sleReferee(mEngine->entryCache(ltACCOUNT_ROOT, Ledger::getAccountRootIndex(refereeID)));
        SLE::pointer sleReference(mEngine->entryCache(ltACCOUNT_ROOT, Ledger::getAccountRootIndex(referenceID)));

        if (!sleReferee) {
            // Referee account does not exist.
            m_journal.trace <<
                "Malformed transaction: Referee account does not exist.";

            return tecNO_DST;
        } else if (!sleReference) {
            // Reference account does not exist.
            m_journal.trace <<
                "Malformed transaction: Reference account does not exist.";

            return terNO_ACCOUNT;
        } else if (sleReference->getFieldAccount(sfReferee).getAccountID().isNonZero())
        {
            // 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: Referee has been set.";

            return tefREFEREE_EXIST;
        }
        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.
            STArray references = sleReferee->getFieldArray(sfReferences);
            for (auto it = references.begin(); it != references.end(); ++it) {
                Account id = it->getFieldAccount(sfReference).getAccountID();
                if (id == referenceID) {
                    m_journal.trace << "Malformed transaction: Reference has been set.";

                    return tefREFERENCE_EXIST;
                }
            }

            mEngine->entryModify(sleReference);
            mEngine->entryModify(sleReferee);
            sleReference->setFieldAccount(sfReferee, refereeID);
            STObject obj;
            obj.setFieldAccount(sfReference, referenceID);
            references.push_back(obj);
            sleReferee->setFieldArray(sfReferences, references);
        }

        return tesSUCCESS;
    }
开发者ID:,项目名称:,代码行数:77,代码来源:


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