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


C++ Blob::begin方法代码示例

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


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

示例1: convertNonCanonical

    void convertNonCanonical(std::string const& hex, std::string const& canonHex)
    {
        Blob b (loadSignature(hex));

        // The signature ought to at least be valid before we begin.
        expect (isValid (hex), "invalid signature");

        size_t len = b.size ();

        expect (!makeCanonicalECDSASig (&b[0], len), 
            "non-canonical signature was already canonical");

        expect (b.size () >= len,
            "canonicalized signature length longer than non-canonical");

        b.resize (len);

        expect (isCanonicalECDSASig (&b[0], len, ECDSA::strict),
            "canonicalized signature is not strictly canonical");

        Blob canonicalForm (loadSignature (canonHex));

        expect (b.size () == canonicalForm.size (),
            "canonicalized signature doesn't have the expected length");

        expect (std::equal (b.begin (), b.end (), canonicalForm.begin ()),
            "canonicalized signature isn't what we expected");
    }
开发者ID:BattleProgrammer,项目名称:stellard,代码行数:28,代码来源:ECDSACanonical.cpp

示例2: gotNode

void ConsensusTransSetSF::gotNode (bool fromFilter, const SHAMapNode& id, uint256 const& nodeHash,
                                   Blob& nodeData, SHAMapTreeNode::TNType type)
{
    if (fromFilter)
        return;

    m_nodeCache.insert (nodeHash, nodeData);

    if ((type == SHAMapTreeNode::tnTRANSACTION_NM) && (nodeData.size () > 16))
    {
        // this is a transaction, and we didn't have it
        WriteLog (lsDEBUG, TransactionAcquire) << "Node on our acquiring TX set is TXN we may not have";

        try
        {
            Serializer s (nodeData.begin () + 4, nodeData.end ()); // skip prefix
            SerializerIterator sit (s);
            SerializedTransaction::pointer stx = boost::make_shared<SerializedTransaction> (boost::ref (sit));
            assert (stx->getTransactionID () == nodeHash);
            getApp().getJobQueue ().addJob (jtTRANSACTION, "TXS->TXN",
                                           BIND_TYPE (&NetworkOPs::submitTransaction, &getApp().getOPs (), P_1, stx));
        }
        catch (...)
        {
            WriteLog (lsWARNING, TransactionAcquire) << "Fetched invalid transaction in proposed set";
        }
    }
}
开发者ID:BattleProgrammer,项目名称:stellard,代码行数:28,代码来源:SHAMapSyncFilters.cpp

示例3: to_currency

bool to_currency(Currency& currency, std::string const& code)
{
    if (code.empty () || !code.compare (systemCurrencyCode()))
    {
        currency = beast::zero;
        return true;
    }

    static const int CURRENCY_CODE_LENGTH = 3;
    if (code.size () == CURRENCY_CODE_LENGTH)
    {
        Blob codeBlob (CURRENCY_CODE_LENGTH);

        std::transform (code.begin (), code.end (), codeBlob.begin (),
                        [](auto c)
                        {
                            return ::toupper(static_cast<unsigned char>(c));
                        });

        Serializer  s;

        s.addZeros (96 / 8);
        s.addRaw (codeBlob);
        s.addZeros (16 / 8);
        s.addZeros (24 / 8);

        s.get160 (currency, 0);
        return true;
    }

    if (40 == code.size ())
        return currency.SetHex (code);

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

示例4: i

bool Base58::raw_decode (char const* first, char const* last, void* dest,
    std::size_t size, bool checked, Alphabet const& alphabet)
{
    CAutoBN_CTX pctx;
    CBigNum bn58 = 58;
    CBigNum bn = 0;
    CBigNum bnChar;

    // Convert big endian string to bignum
    for (char const* p = first; p != last; ++p)
    {
        int i (alphabet.from_char (*p));
        if (i == -1)
            return false;
        bnChar.setuint ((unsigned int) i);

        int const success (BN_mul (&bn, &bn, &bn58, pctx));

        assert (success);
        (void) success;

        bn += bnChar;
    }

    // Get bignum as little endian data
    Blob vchTmp = bn.getvch ();

    // Trim off sign byte if present
    if (vchTmp.size () >= 2 && vchTmp.end ()[-1] == 0 && vchTmp.end ()[-2] >= 0x80)
        vchTmp.erase (vchTmp.end () - 1);

    char* const out (static_cast <char*> (dest));

    // Count leading zeros
    int nLeadingZeros = 0;
    for (char const* p = first; p!=last && *p==alphabet[0]; p++)
        nLeadingZeros++;

    // Verify that the size is correct
    if (vchTmp.size() + nLeadingZeros != size)
        return false;

    // Fill the leading zeros
    memset (out, 0, nLeadingZeros);

    // Copy little endian data to big endian
    std::reverse_copy (vchTmp.begin (), vchTmp.end (),
        out + nLeadingZeros);

    if (checked)
    {
        char hash4 [4];
        fourbyte_hash256 (hash4, out, size - 4);
        if (memcmp (hash4, out + size - 4, 4) != 0)
            return false;
    }

    return true;
}
开发者ID:alexandrev,项目名称:rippled,代码行数:59,代码来源:Base58.cpp

示例5: human

std::string RippleAddress::human(Blob& blob, VersionEncoding type)
{
	Blob vch(1, type);
	
	vch.insert(vch.end(), blob.begin(), blob.end());

	return Base58::encodeWithCheck(vch);
}
开发者ID:Payshares,项目名称:paysharesd,代码行数:8,代码来源:RippleAddress.cpp

示例6: bignum_error

bool Base58::decode (const char* psz, Blob& vchRet, Alphabet const& alphabet)
{
    CAutoBN_CTX pctx;
    vchRet.clear ();
    CBigNum bn58 = 58;
    CBigNum bn = 0;
    CBigNum bnChar;

    while (isspace (*psz))
        psz++;

    // Convert big endian string to bignum
    for (const char* p = psz; *p; p++)
    {
        // VFALCO TODO Make this use the inverse table!
        //             Or better yet ditch this and call raw_decode
        //
        const char* p1 = strchr (alphabet.chars(), *p);

        if (p1 == nullptr)
        {
            while (isspace (*p))
                p++;

            if (*p != '\0')
                return false;

            break;
        }

        bnChar.setuint (p1 - alphabet.chars());

        if (!BN_mul (&bn, &bn, &bn58, pctx))
            throw bignum_error ("DecodeBase58 : BN_mul failed");

        bn += bnChar;
    }

    // Get bignum as little endian data
    Blob vchTmp = bn.getvch ();

    // Trim off sign byte if present
    if (vchTmp.size () >= 2 && vchTmp.end ()[-1] == 0 && vchTmp.end ()[-2] >= 0x80)
        vchTmp.erase (vchTmp.end () - 1);

    // Restore leading zeros
    int nLeadingZeros = 0;

    for (const char* p = psz; *p == alphabet.chars()[0]; p++)
        nLeadingZeros++;

    vchRet.assign (nLeadingZeros + vchTmp.size (), 0);

    // Convert little endian data to big endian
    std::reverse_copy (vchTmp.begin (), vchTmp.end (), vchRet.end () - vchTmp.size ());
    return true;
}
开发者ID:CCJY,项目名称:rippled,代码行数:57,代码来源:Base58.cpp

示例7: strCopy

Blob strCopy (std::string const& strSrc)
{
    Blob vucDst;

    vucDst.resize (strSrc.size ());

    std::copy (strSrc.begin (), strSrc.end (), vucDst.begin ());

    return vucDst;
}
开发者ID:CFQuantum,项目名称:CFQuantumd,代码行数:10,代码来源:StringUtilities.cpp

示例8: getBinary

Blob SqliteDatabase::getBinary (int colIndex)
{
    const unsigned char*        blob    = reinterpret_cast<const unsigned char*> (sqlite3_column_blob (mCurrentStmt, colIndex));
    size_t                      iSize   = sqlite3_column_bytes (mCurrentStmt, colIndex);
    Blob    vucResult;

    vucResult.resize (iSize);
    std::copy (blob, blob + iSize, vucResult.begin ());

    return vucResult;
}
开发者ID:MonsieurNicolas,项目名称:stellard,代码行数:11,代码来源:SqliteDatabase.cpp

示例9: STBase

STVector256::STVector256(SerialIter& sit, SField const& name)
    : STBase(name)
{
    Blob data = sit.getVL ();
    auto const count = data.size () / (256 / 8);
    mValue.reserve (count);
    Blob::iterator begin = data.begin ();
    unsigned int uStart  = 0;
    for (unsigned int i = 0; i != count; i++)
    {
        unsigned int uEnd = uStart + (256 / 8);
        // This next line could be optimized to construct a default
        // uint256 in the vector and then copy into it
        mValue.push_back (uint256 (Blob (begin + uStart, begin + uEnd)));
        uStart  = uEnd;
    }
}
开发者ID:CFQuantum,项目名称:CFQuantumd,代码行数:17,代码来源:STVector256.cpp

示例10: ConvertToBase58

String ConvertToBase58(const ConstBuf& cbuf) {
	HashValue hash = HasherEng::GetCurrent()->HashForAddress(cbuf);
	Blob v = cbuf + Blob(hash.data(), 4);
	vector<char> r;

	vector<byte> tmp(v.Size+1, 0);
	std::reverse_copy(v.begin(), v.end(), tmp.begin());
	for (BigInteger n(&tmp[0], tmp.size()); Sign(n);) {
		pair<BigInteger, BigInteger> pp = div(n, 58);
		n = pp.first;
		r.insert(r.begin(), s_pszBase58[explicit_cast<int>(pp.second)]);
	}

	for (int i=0; i<v.Size && !v.constData()[i]; ++i)
		r.insert(r.begin(), s_pszBase58[0]);
	return String(&r[0], r.size());
}
开发者ID:Groestlcoin,项目名称:Groestlcoin-WPF,代码行数:17,代码来源:base58.cpp

示例11: ConvertToBase58ShaSquare

String ConvertToBase58ShaSquare(const ConstBuf& cbuf) {
	SHA256 sha;
	HashValue hash = HashValue(sha.ComputeHash(sha.ComputeHash(cbuf)));
	Blob v = cbuf + Blob(hash.data(), 4);
	vector<char> r;

	vector<byte> tmp(v.Size+1, 0);
	std::reverse_copy(v.begin(), v.end(), tmp.begin());
	for (BigInteger n(&tmp[0], tmp.size()); Sign(n);) {
		pair<BigInteger, BigInteger> pp = div(n, 58);
		n = pp.first;
		r.insert(r.begin(), s_pszBase58[explicit_cast<int>(pp.second)]);
	}

	for (int i=0; i<v.Size && !v.constData()[i]; ++i)
		r.insert(r.begin(), s_pszBase58[0]);
	return String(&r[0], r.size());
}
开发者ID:Groestlcoin,项目名称:Groestlcoin-WPF,代码行数:18,代码来源:base58.cpp

示例12:

bool Base58::decodeWithCheck (const char* psz, Blob& vchRet, Alphabet const& alphabet)
{
    if (!decode (psz, vchRet, alphabet))
        return false;

    if (vchRet.size () < 4)
    {
        vchRet.clear ();
        return false;
    }

    uint256 hash = SHA256Hash (vchRet.begin (), vchRet.end () - 4);

    if (memcmp (&hash, &vchRet.end ()[-4], 4) != 0)
    {
        vchRet.clear ();
        return false;
    }

    vchRet.resize (vchRet.size () - 4);
    return true;
}
开发者ID:CCJY,项目名称:rippled,代码行数:22,代码来源:Base58.cpp

示例13: vec

// Return a new object from a SerializerIterator.
STVector256* STVector256::construct (SerializerIterator& u, SField::ref name)
{
    Blob data = u.getVL ();
    Blob ::iterator begin = data.begin ();

    std::unique_ptr<STVector256> vec (new STVector256 (name));

    int count = data.size () / (256 / 8);
    vec->mValue.reserve (count);

    unsigned int    uStart  = 0;

    for (unsigned int i = 0; i != count; i++)
    {
        unsigned int    uEnd    = uStart + (256 / 8);

        // This next line could be optimized to construct a default uint256 in the vector and then copy into it
        vec->mValue.push_back (uint256 (Blob (begin + uStart, begin + uEnd)));
        uStart  = uEnd;
    }

    return vec.release ();
}
开发者ID:BattleProgrammer,项目名称:stellard,代码行数:24,代码来源:SerializedTypes.cpp

示例14: s


//.........这里部分代码省略.........
        else if (type == 4)
        {
            // transaction with metadata
            if (len < (256 / 8))
                throw std::runtime_error ("short TM node");

            uint256 u;
            s.get256 (u, len - (256 / 8));
            s.chop (256 / 8);

            if (u.isZero ())
                throw std::runtime_error ("invalid TM node");

            mItem = boost::make_shared<SHAMapItem> (u, s.peekData ());
            mType = tnTRANSACTION_MD;
        }
    }

    else if (format == snfPREFIX)
    {
        if (rawNode.size () < 4)
        {
            WriteLog (lsINFO, SHAMapNode) << "size < 4";
            throw std::runtime_error ("invalid P node");
        }

        uint32 prefix = rawNode[0];
        prefix <<= 8;
        prefix |= rawNode[1];
        prefix <<= 8;
        prefix |= rawNode[2];
        prefix <<= 8;
        prefix |= rawNode[3];
        Serializer s (rawNode.begin () + 4, rawNode.end ());

        if (prefix == HashPrefix::transactionID)
        {
            mItem = boost::make_shared<SHAMapItem> (Serializer::getSHA512Half (rawNode), s.peekData ());
            mType = tnTRANSACTION_NM;
        }
        else if (prefix == HashPrefix::leafNode)
        {
            if (s.getLength () < 32)
                throw std::runtime_error ("short PLN node");

            uint256 u;
            s.get256 (u, s.getLength () - 32);
            s.chop (32);

            if (u.isZero ())
            {
                WriteLog (lsINFO, SHAMapNode) << "invalid PLN node";
                throw std::runtime_error ("invalid PLN node");
            }

            mItem = boost::make_shared<SHAMapItem> (u, s.peekData ());
            mType = tnACCOUNT_STATE;
        }
        else if (prefix == HashPrefix::innerNode)
        {
            if (s.getLength () != 512)
                throw std::runtime_error ("invalid PIN node");

            for (int i = 0; i < 16; ++i)
            {
                s.get256 (mHashes[i], i * 32);
开发者ID:Aiolossong,项目名称:rippled,代码行数:67,代码来源:SHAMapTreeNode.cpp

示例15: load

 friend bool load(Blob const& blob, SpecificMessage& msg) {
     msg.contents.assign(blob.begin(), blob.end());
     return true;
 }
开发者ID:CCJY,项目名称:coliru,代码行数:4,代码来源:main.cpp


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