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


C++ data_buffer::read_sha256方法代码示例

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


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

示例1: decode

bool incentive_vote::decode(data_buffer & buffer)
{
    /**
     * Read the version.
     */
    m_version = buffer.read_uint32();
    
    assert(m_version == current_version);
    
    /**
     * Read the block height.
     */
    m_block_height = buffer.read_uint32();
    
    /**
     * Read the block hash.
     */
    m_hash_block = buffer.read_sha256();
    
    /**
     * Read the nonce hash.
     */
    m_hash_nonce = buffer.read_sha256();
    
    /**
     * Read the number of address length.
     */
    auto address_len = buffer.read_var_int();
    
    /**
     * Allocate the address.
     */
    m_address.resize(address_len);
    
    /**
     * Read the address.
     */
    buffer.read_bytes(const_cast<char *>(m_address.data()), m_address.size());
    
    /**
     * Decode the public key.
     */
    m_public_key.decode(buffer);

    /**
     * Check the hash nonce is correct.
     */
    if (
        m_hash_nonce != (m_hash_block ^ sha256::from_digest(&hash::sha256d(
        reinterpret_cast<const std::uint8_t *> (
        m_address.data()), m_address.size())[0]) ^ m_public_key.get_hash())
        )
    {
        log_error("Incentive vote decode failed, invalid nonce.");
        
        return false;
    }

    return verify(buffer);
}
开发者ID:machado-rev,项目名称:vcash,代码行数:60,代码来源:incentive_vote.cpp

示例2: decode

bool checkpoint_sync_unsigned::decode(data_buffer & buffer)
{
    m_version = buffer.read_int32();
    m_hash_checkpoint = buffer.read_sha256();
    
    return true;
}
开发者ID:xCoreDev,项目名称:vcash,代码行数:7,代码来源:checkpoint_sync_unsigned.cpp

示例3: decode

bool inventory_vector::decode(data_buffer & buffer)
{
    m_type = static_cast<type_t> (buffer.read_uint32());
    m_hash = buffer.read_sha256();
    
    return true;
}
开发者ID:jaggedMiner,项目名称:vanillacoin,代码行数:7,代码来源:inventory_vector.cpp

示例4: decode

bool merkle_tree_partial::decode(data_buffer & buffer)
{
    m_total_transactions = buffer.read_uint32();
    
    auto count = buffer.read_var_int();
    
    for (auto i = 0; i < count; i++)
    {
        m_hashes.push_back(buffer.read_sha256());
    }
    
    std::vector<std::uint8_t> bytes;
    
    auto len = buffer.read_var_int();
    
    if (len > 0)
    {
        bytes.resize(len);
        
        buffer.read_bytes(reinterpret_cast<char *>(&bytes[0]), len);
    }
    
    m_flags.resize(bytes.size() * 8);
    
    for (auto i = 0; i < m_flags.size(); i++)
    {
        m_flags[i] = (bytes[i / 8] & (1 << (i % 8))) != 0;
    }
    
    is_invalid_ = false;
    
    return true;
}
开发者ID:rafaelfelicio,项目名称:vcash-1,代码行数:33,代码来源:merkle_tree_partial.cpp

示例5: decode

bool chainblender_join::decode(data_buffer & buffer)
{
    /**
     * Decode the version.
     */
    m_version = buffer.read_uint32();
    
    assert(m_version == current_version);
    
    /**
     * Decode the session id.
     */
    m_hash_session_id = buffer.read_sha256();
    
    /**
     * Read the denomination.
     */
    m_denomination = buffer.read_int64();
    
    return true;
}
开发者ID:greenmo000,项目名称:vcash,代码行数:21,代码来源:chainblender_join.cpp

示例6: read_key_value

bool db_wallet::read_key_value(
    wallet & w, data_buffer & buffer_key,
    data_buffer & buffer_value, std::int32_t & file_version,
    std::vector<sha256> & wallet_upgrade, bool & is_encrypted,
    bool & any_unordered, std::string & type, std::string & err
    )
 {
    type.clear();
    type.resize(buffer_key.read_var_int());
    
    buffer_key.read_bytes(
        const_cast<char *> (type.data()), type.size()
    );

    if (type == "name")
    {
        std::string addr;
        
        auto len = buffer_key.read_var_int();
        
        if (len > 0)
        {
            addr.resize(len);
            
            buffer_key.read_bytes(
                const_cast<char *> (addr.data()), addr.size()
            );
        }
        
        std::string value;
        
        len = buffer_value.read_var_int();
        
        if (len > 0)
        {
            value.resize(len);
            
            buffer_value.read_bytes(
                const_cast<char *> (value.data()), value.size()
            );
        }
        
        w.address_book()[address(addr).get()] = value;
    }
    else if (type == "tx")
    {
        sha256 hash = buffer_key.read_sha256();

        auto & wtx = w.transactions()[hash];
        
        wtx.decode(buffer_value);

        if (wtx.get_hash() == hash)
        {
            wtx.bind_wallet(w);
        }
        else
        {
            w.transactions().erase(hash);
            
            return false;
        }

        /**
         * Undo serialize changes in 31600.
         */
        if (
            31404 <= wtx.time_received_is_tx_time() &&
            wtx.time_received_is_tx_time() <= 31703
            )
        {
            if (buffer_value.remaining() > 0)
            {
                char tmp;
                char unused;
                
                buffer_value.read_bytes(&tmp, sizeof(tmp));
                buffer_value.read_bytes(&unused, sizeof(unused));
                
                wtx.from_account().clear();
                wtx.from_account().resize(buffer_value.read_var_int());
                
                buffer_value.read_bytes(
                    const_cast<char *> (wtx.from_account().data()),
                    wtx.from_account().size()
                );
                
                wtx.set_time_received_is_tx_time(tmp);
            }
            else
            {
                wtx.set_time_received_is_tx_time(0);
            }
            
            wallet_upgrade.push_back(hash);
        }

        if (wtx.order_position() == -1)
        {
            any_unordered = true;
//.........这里部分代码省略.........
开发者ID:tempbottle,项目名称:vanillacoin,代码行数:101,代码来源:db_wallet.cpp


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