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


C++ uint256::isNonZero方法代码示例

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


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

示例1: findCreate

    // VFALCO TODO Should this be called findOrAdd ?
    //
    InboundLedger::pointer findCreate (uint256 const& hash, std::uint32_t seq, InboundLedger::fcReason reason)
    {
        assert (hash.isNonZero ());
        InboundLedger::pointer ret;

        // Ensure that any previous IL is destroyed outside the lock
        InboundLedger::pointer oldLedger;

        {
            ScopedLockType sl (mLock);

            if (! isStopping ())
            {

                if (reason == InboundLedger::fcCONSENSUS)
                {
                    if (mConsensusLedger.isNonZero() && (mValidationLedger != mConsensusLedger) && (hash != mConsensusLedger))
                    {
                        hash_map<uint256, InboundLedger::pointer>::iterator it = mLedgers.find (mConsensusLedger);
                        if (it != mLedgers.end ())
                        {
                            oldLedger = it->second;
                            mLedgers.erase (it);
                        }
                    }
                    mConsensusLedger = hash;
                }
                else if (reason == InboundLedger::fcVALIDATION)
                {
                    if (mValidationLedger.isNonZero() && (mValidationLedger != mConsensusLedger) && (hash != mValidationLedger))
                    {
                        hash_map<uint256, InboundLedger::pointer>::iterator it = mLedgers.find (mValidationLedger);
                        if (it != mLedgers.end ())
                        {
                            oldLedger = it->second;
                            mLedgers.erase (it);
                       }
                    }
                    mValidationLedger = hash;
                }

                hash_map<uint256, InboundLedger::pointer>::iterator it = mLedgers.find (hash);
                if (it != mLedgers.end ())
                {
                    ret = it->second;
                    // FIXME: Should set the sequence if it's not set
                }
                else
                {
                    ret = std::make_shared <InboundLedger> (hash, seq, reason, std::ref (m_clock));
                    assert (ret);
                    mLedgers.insert (std::make_pair (hash, ret));
                    ret->init (sl);
                    ++mCounter;
                }
            }
        }

        return ret;
    }
开发者ID:BobWay,项目名称:rippled,代码行数:62,代码来源:InboundLedgers.cpp

示例2: acquire

    Ledger::pointer acquire (uint256 const& hash, std::uint32_t seq, InboundLedger::fcReason reason)
    {
        assert (hash.isNonZero ());
        InboundLedger::pointer inbound;
        {
            ScopedLockType sl (mLock);

            if (! isStopping ())
            {
                auto it = mLedgers.find (hash);
                if (it != mLedgers.end ())
                {
                    inbound = it->second;

                    // If the acquisition failed, don't mark the item as
                    // recently accessed so that it can expire.
                    if (! inbound->isFailed ())
                        inbound->update (seq);
                }
                else
                {
                    inbound = std::make_shared <InboundLedger> (
                        hash, seq, reason, std::ref (m_clock));
                    mLedgers.emplace (hash, inbound);
                    inbound->init (sl);
                    ++mCounter;
                }
            }
        }
        if (inbound && inbound->isComplete ())
            return inbound->getLedger();
        return {};
    }
开发者ID:xdv,项目名称:divvyd,代码行数:33,代码来源:InboundLedgers.cpp

示例3: hasLedger

bool InboundLedgers::hasLedger (uint256 const& hash)
{
    assert (hash.isNonZero ());

    boost::mutex::scoped_lock sl (mLock);
    return mLedgers.find (hash) != mLedgers.end ();
}
开发者ID:AUSTRALIANBITCOINS,项目名称:rippled,代码行数:7,代码来源:ripple_InboundLedgers.cpp

示例4: sl

    std::shared_ptr<Ledger const>
    acquire(uint256 const& hash, std::uint32_t seq,
        InboundLedger::Reason reason) override
    {
        assert(hash.isNonZero());
        assert(reason != InboundLedger::Reason::SHARD ||
            (seq != 0 && app_.getShardStore()));
        if (isStopping())
            return {};

        bool isNew = true;
        std::shared_ptr<InboundLedger> inbound;
        {
            ScopedLockType sl(mLock);
            auto it = mLedgers.find(hash);
            if (it != mLedgers.end())
            {
                isNew = false;
                inbound = it->second;
            }
            else
            {
                inbound = std::make_shared <InboundLedger>(
                    app_, hash, seq, reason, std::ref(m_clock));
                mLedgers.emplace(hash, inbound);
                inbound->init(sl);
                ++mCounter;
            }
        }

        if (inbound->isFailed())
            return {};

        if (! isNew)
            inbound->update(seq);

        if (! inbound->isComplete())
            return {};

        if (reason == InboundLedger::Reason::HISTORY)
        {
            if (inbound->getLedger()->stateMap().family().isShardBacked())
                app_.getNodeStore().copyLedger(inbound->getLedger());
        }
        else if (reason == InboundLedger::Reason::SHARD)
        {
            auto shardStore = app_.getShardStore();
            if (!shardStore)
            {
                JLOG(j_.error()) <<
                    "Acquiring shard with no shard store available";
                return {};
            }
            if (inbound->getLedger()->stateMap().family().isShardBacked())
                shardStore->setStored(inbound->getLedger());
            else
                shardStore->copyLedger(inbound->getLedger());
        }
        return inbound->getLedger();
    }
开发者ID:Empresaria,项目名称:rippled,代码行数:60,代码来源:InboundLedgers.cpp

示例5: findCreate

InboundLedger::pointer InboundLedgers::findCreate (uint256 const& hash, uint32 seq)
{
    assert (hash.isNonZero ());
    boost::mutex::scoped_lock sl (mLock);
    InboundLedger::pointer& ptr = mLedgers[hash];

    if (ptr)
    {
        ptr->touch ();
        return ptr;
    }

    ptr = boost::make_shared<InboundLedger> (hash, seq);

    if (!ptr->isDone ())
    {
        ptr->addPeers ();
        ptr->setTimer (); // Cannot call in constructor
    }
    else
    {
        Ledger::pointer ledger = ptr->getLedger ();
        ledger->setClosed ();
        ledger->setImmutable ();
        theApp->getLedgerMaster ().storeLedger (ledger);
        WriteLog (lsDEBUG, InboundLedger) << "Acquiring ledger we already have: " << hash;
    }

    return ptr;
}
开发者ID:justmoon,项目名称:rippled,代码行数:30,代码来源:ripple_InboundLedgers.cpp

示例6: dropLedger

void InboundLedgers::dropLedger (uint256 const& hash)
{
    assert (hash.isNonZero ());

    boost::mutex::scoped_lock sl (mLock);
    mLedgers.erase (hash);

}
开发者ID:AUSTRALIANBITCOINS,项目名称:rippled,代码行数:8,代码来源:ripple_InboundLedgers.cpp

示例7: find

InboundLedger::pointer InboundLedgers::find (uint256 const& hash)
{
    assert (hash.isNonZero ());
    boost::mutex::scoped_lock sl (mLock);
    std::map<uint256, InboundLedger::pointer>::iterator it = mLedgers.find (hash);

    if (it != mLedgers.end ())
    {
        it->second->touch ();
        return it->second;
    }

    return InboundLedger::pointer ();
}
开发者ID:justmoon,项目名称:rippled,代码行数:14,代码来源:ripple_InboundLedgers.cpp

示例8: setChildHash

bool SHAMapTreeNode::setChildHash (int m, uint256 const& hash)
{
    assert ((m >= 0) && (m < 16));
    assert (mType == tnINNER);

    if (mHashes[m] == hash)
        return false;

    mHashes[m] = hash;

    if (hash.isNonZero ())
        mIsBranch |= (1 << m);
    else
        mIsBranch &= ~ (1 << m);

    return updateHash ();
}
开发者ID:Aiolossong,项目名称:rippled,代码行数:17,代码来源:SHAMapTreeNode.cpp

示例9: find

    InboundLedger::pointer find (uint256 const& hash)
    {
        assert (hash.isNonZero ());

        InboundLedger::pointer ret;

        {
            ScopedLockType sl (mLock);

            hash_map<uint256, InboundLedger::pointer>::iterator it = mLedgers.find (hash);
            if (it != mLedgers.end ())
            {
                ret = it->second;
            }
        }

        return ret;
    }
开发者ID:xdv,项目名称:divvyd,代码行数:18,代码来源:InboundLedgers.cpp

示例10: find

InboundLedger::pointer InboundLedgers::find (uint256 const& hash)
{
    assert (hash.isNonZero ());

    InboundLedger::pointer ret;

    {
        boost::mutex::scoped_lock sl (mLock);

        boost::unordered_map<uint256, InboundLedger::pointer>::iterator it = mLedgers.find (hash);
        if (it != mLedgers.end ())
        {
            ret = it->second;
        }
    }

    return ret;
}
开发者ID:AUSTRALIANBITCOINS,项目名称:rippled,代码行数:18,代码来源:ripple_InboundLedgers.cpp

示例11: findCreate

InboundLedger::pointer InboundLedgers::findCreate (uint256 const& hash, uint32 seq)
{
    assert (hash.isNonZero ());
    InboundLedger::pointer ret;

    {
        boost::mutex::scoped_lock sl (mLock);

        boost::unordered_map<uint256, InboundLedger::pointer>::iterator it = mLedgers.find (hash);
        if (it != mLedgers.end ())
        {
            ret = it->second;
            // FIXME: Should set the sequence if it's not set
        }
        else
        {
            ret = boost::make_shared<InboundLedger> (hash, seq);
            assert (ret);
            mLedgers.insert (std::make_pair (hash, ret));

            if (!ret->tryLocal())
            {
                ret->addPeers ();
                ret->setTimer (); // Cannot call in constructor
            }
            else if (!ret->isFailed ())
            {
                WriteLog (lsDEBUG, InboundLedger) << "Acquiring ledger we already have locally: " << hash;
                Ledger::pointer ledger = ret->getLedger ();
                ledger->setClosed ();
                ledger->setImmutable ();
                getApp().getLedgerMaster ().storeLedger (ledger);
            }
        }
    }

    return ret;
}
开发者ID:AUSTRALIANBITCOINS,项目名称:rippled,代码行数:38,代码来源:ripple_InboundLedgers.cpp


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