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


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

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


在下文中一共展示了data_buffer::read_uint32方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 hd_configuration::decode(data_buffer & buffer)
{
    m_version = buffer.read_uint32();
    m_index = buffer.read_uint32();
    buffer.read_bytes(
        reinterpret_cast<char *> (&m_id_key_master.digest()[0]),
        ripemd160::digest_length
    );

    return true;
}
开发者ID:xCoreDev,项目名称:vcash,代码行数:11,代码来源:hd_configuration.cpp

示例3: decode

bool zerotime_question::decode(data_buffer & buffer)
{
    /**
     * Decode the version.
     */
    m_version = buffer.read_uint32();
    
    assert(m_version == current_version);
    
    /**
     * Decode the transaction inputs length.
     */
    auto len = buffer.read_var_int();

    /**
     * Allocate the transaction inputs.
     */
    m_transactions_in.resize(len);
    
    for (auto i = 0; i < len; i++)
    {
        /**
         * Decode the transaction_in.
         */
        m_transactions_in[i].decode(buffer);
    }
    
    return true;
}
开发者ID:greenmo000,项目名称:vcash,代码行数:29,代码来源:zerotime_question.cpp

示例4: 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

示例5: 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

示例6: decode

void key_wallet::decode(data_buffer & buffer)
{
    /**
     * Read the version.
     */
    buffer.read_uint32();
    
    /**
     * Read the private key length.
     */
    auto len = buffer.read_var_int();

    if (len > 0)
    {
        /**
         * Read the private key.
         */
        m_key_private.reserve(len);
        
        buffer.read_bytes(
            reinterpret_cast<char *> (&m_key_private[0]), m_key_private.size()
        );
    }
    
    /**
     * Read the time created.
     */
    m_time_created = buffer.read_int64();
    
    /**
     * Read the time expires.
     */
    m_time_expires = buffer.read_int64();
    
    /**
     * Read the comment length.
     */
    len = buffer.read_var_int();
    
    if (len > 0)
    {
        /**
         * Read the comment.
         */
        m_comment.reserve(len);
        
        buffer.read_bytes(
            const_cast<char *> (m_comment.data()), m_comment.size()
        );
    }
}
开发者ID:machado-rev,项目名称:vcash,代码行数:51,代码来源:key_wallet.cpp

示例7: decode

bool zerotime_lock::decode(data_buffer & buffer)
{
    /**
     * Decode the version.
     */
    m_version = buffer.read_uint32();

    assert(m_version == current_version);

    /**
     * Decode the transaction.
     */
    m_transaction.decode(buffer);

    /**
     * Decode the transaction hash.
     */
    buffer.read_bytes(
        reinterpret_cast<char *> (m_hash_tx.digest()), sha256::digest_length
    );

    assert(m_transaction.get_hash() == m_hash_tx);

    /**
     * Decode the expiration.
     */
    m_expiration = buffer.read_uint64();

    /**
     * Enforce the expiration.
     */
    if (
        m_expiration < time::instance().get_adjusted() + interval_min_expire ||
        m_expiration > time::instance().get_adjusted() + interval_max_expire
    )
    {
        m_expiration = time::instance().get_adjusted() + interval_min_expire;
    }

    /**
     * No signature is required because:
     * 1. The receiver may want to lock a non-zerotime transaction.
     * 2. It causes no harm to let other's lock the transaction.
     * 3. It conserves bandwidth and processing power.
     */

    return m_transaction.get_hash() == m_hash_tx;
}
开发者ID:tempbottle,项目名称:vanillacoin,代码行数:48,代码来源:zerotime_lock.cpp

示例8: decode

void key_pool::decode(data_buffer & buffer, const bool & include_version)
{
    if (include_version)
    {
        /**
         * Read the version.
         */
        buffer.read_uint32();
    }
    
    /**
     * Read the time.
     */
    m_time = buffer.read_int64();
    
    /**
     * Decode the public key.
     */
    m_key_public.decode(buffer);
}
开发者ID:machado-rev,项目名称:vcash,代码行数:20,代码来源:key_pool.cpp

示例9: decode

bool incentive_answer::decode(data_buffer & buffer)
{
    /**
     * Decode the version.
     */
    m_version = buffer.read_uint32();
    
    assert(m_version == current_version);
    
    /**
     * Decode the key_public.
     */
    m_public_key.decode(buffer);
    
    /**
     * Decode the transaction_in.
     */
    m_transaction_in.decode(buffer);
    
    return verify(buffer);
}
开发者ID:machado-rev,项目名称:vcash,代码行数:21,代码来源:incentive_answer.cpp

示例10: 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

示例11: read_key_value


//.........这里部分代码省略.........
            k.set_public_key(pub_key);
            
            if (k.set_private_key(wkey.key_private()) == false)
            {
                err = "private key is corrupt";
                
                return false;
            }
            
            if (k.get_public_key() != pub_key)
            {
                err = "public key inconsistency";
                
                return false;
            }
            
            if (k.is_valid() == false)
            {
                err = "invalid wallet key";
                
                return false;
            }
        }
        
        if (w.load_key(k) == false)
        {
            err = "load key failed";
            
            return false;
        }
    }
    else if (type == "mkey")
    {
        auto id = buffer_key.read_uint32();
        
        key_wallet_master master_key;
        
        master_key.decode(buffer_value);
        
        if (w.master_keys().count(id) != 0)
        {
            err = "duplicate master key id " + std::to_string(id);
            
            return false;
        }
        
        w.master_keys()[id] = master_key;
        
        if (w.master_key_max_id() < id)
        {
            w.set_master_key_max_id(id);
        }
    }
    else if (type == "ckey")
    {
        std::vector<std::uint8_t> pub_key;
        
        auto len = buffer_key.read_var_int();
        
        if (len > 0)
        {
            pub_key.resize(len);
            buffer_key.read_bytes(
                reinterpret_cast<char *> (&pub_key[0]), pub_key.size()
            );
        }
开发者ID:tempbottle,项目名称:vanillacoin,代码行数:67,代码来源:db_wallet.cpp

示例12: decode

bool transaction::decode(data_buffer & buffer)
{
    /**
     * Read the version.
     */
    m_version = buffer.read_uint32();

    /**
     * Read the time.
     */
    m_time = buffer.read_uint32();
    
    /**
     * Read the number of transactions in.
     */
    auto number_transactions_in = buffer.read_var_int();
    
    for (auto i = 0; i < number_transactions_in; i++)
    {
        /**
         * Allocate the transaction_in.
         */
        transaction_in tx_in;
        
        /**
         * Decode the transaction_in.
         */
        tx_in.decode(buffer);

        /**
         * Retain the transaction_in.
         */
        m_transactions_in.push_back(tx_in);
    }
    
    /**
     * Read the number of transactions out.
     */
    auto number_transactions_out = buffer.read_var_int();
    
    for (auto i = 0; i < number_transactions_out; i++)
    {
        /**
         * Allocate the transaction_out.
         */
        transaction_out tx_out;
        
        /**
         * Decode the transaction_out.
         */
        tx_out.decode(buffer);

        /**
         * Retain the transaction_out.
         */
        m_transactions_out.push_back(tx_out);
    }
    
    /**
     * Decode the time lock.
     */
    m_time_lock = buffer.read_uint32();
    
    return true;
}
开发者ID:xCoreDev,项目名称:vcash,代码行数:65,代码来源:transaction.cpp

示例13: decode

bool incentive_collaterals::decode(data_buffer & buffer)
{
    /**
     * Decode the version.
     */
    m_version = buffer.read_uint32();
    
    assert(m_version == current_version);
    
    /**
     * Read the number of collateral entries.
     */
    auto count = buffer.read_var_int();
    
    /**
     * Read each collateral entry.
     */
    for (auto i = 0; i < count; i++)
    {
        address_manager::recent_endpoint_t collateral;
        
        /**
         * Read the address.
         */
        collateral.addr = buffer.read_network_address(false, true);
        
        auto len = buffer.read_var_int();
        
        collateral.wallet_address.resize(len);
        
        /**
         * Read the wallet address.
         */
        buffer.read_bytes(
            const_cast<char *> (collateral.wallet_address.data()),
            collateral.wallet_address.size()
        );
        
        /**
         * Read the public key.
         */
        collateral.public_key.decode(buffer);
        
        /**
         * Read the transaction_in.
         */
        collateral.tx_in.decode(buffer);
        
        /**
         * Read the time.
         */
        collateral.time = buffer.read_uint64();
        
        /**
         * Read the protocol version.
         */
        collateral.protocol_version = buffer.read_uint32();
        
        /**
         * Read the protocol version user agent length.
         */
        len = buffer.read_var_int();
        
        collateral.protocol_version_user_agent.resize(len);
        
        /**
         * Read the protocol version user agent.
         */
        buffer.read_bytes(
            const_cast<char *> (collateral.protocol_version_user_agent.data()),
            collateral.protocol_version_user_agent.size()
        );
        
        /**
         * Read the protocol version services.
         */
        collateral.protocol_version_services = buffer.read_uint64();
        
        /**
         * Read the protocol version start height.
         */
        collateral.protocol_version_start_height = buffer.read_int32();
        
        m_collaterals.insert(collateral);
    }
    
    return true;
}
开发者ID:xCoreDev,项目名称:vcash,代码行数:88,代码来源:incentive_collaterals.cpp

示例14: decode

void transaction_wallet::decode(data_buffer & buffer)
{
    /**
     * Initialize
     */
    initialize(0);
    
    auto is_spent = false;

    /**
     * Decode the base class.
     */
    transaction_merkle::decode(buffer);
    
    auto len = buffer.read_var_int();
    
    for (auto i = 0; i < len; i++)
    {
        transaction_merkle tx_merkle;
        
        tx_merkle.decode(buffer);
        
        m_previous_transactions.push_back(tx_merkle);
    }
    
    auto len_values = buffer.read_var_int();
    
    for (auto i = 0; i < len_values; i++)
    {
        std::string first(buffer.read_var_int(), 0);
        
        buffer.read_bytes(const_cast<char *> (first.data()), first.size());
        
        std::string second(buffer.read_var_int(), 0);
        
        buffer.read_bytes(const_cast<char *> (second.data()), second.size());
        
        m_values[first] = second;
    }
    
    m_order_form.resize(buffer.read_var_int());
    
    for (auto i = 0; i < m_order_form.size(); i++)
    {
        std::string first(buffer.read_var_int(), 0);
        
        buffer.read_bytes(const_cast<char *> (first.data()), first.size());
        
        std::string second(buffer.read_var_int(), 0);
        
        buffer.read_bytes(const_cast<char *> (second.data()), second.size());
        
        m_order_form[i] = std::make_pair(first, second);
    }

    m_time_received_is_tx_time = buffer.read_uint32();

    m_time_received = buffer.read_uint32();
    
    m_is_from_me = buffer.read_uint8();
    
    is_spent = buffer.read_uint8();
    
    m_from_account = m_values["fromaccount"];

    if (m_values.count("spent") > 0)
    {
        for (auto & i : m_values["spent"])
        {
            m_spent.push_back(i != '0');
        }
    }
    else
    {
        m_spent.assign(transaction_out().size(), is_spent);
    }
    
    /**
     * If we are an (SPV) client set the block height from the value.
     */
    if (globals::instance().is_client_spv() == true)
    {
        if (m_values.count("spv_block_height") > 0)
        {
            auto block_height = std::stoi(m_values["spv_block_height"]);
            
            set_spv_block_height(block_height);
        }
    }
    
    /**
     * Read the order position.
     */
    wallet::read_order_position(m_order_position, m_values);

    m_time_smart =
        m_values.count("timesmart") ?
        boost::lexical_cast<std::uint32_t> (m_values["timesmart"]) : 0
    ;

//.........这里部分代码省略.........
开发者ID:xCoreDev,项目名称:vcash,代码行数:101,代码来源:transaction_wallet.cpp


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