• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ data_buffer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

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


示例2: decode

bool checkpoint_sync::decode(data_buffer & buffer)
{
    auto len = buffer.read_var_int();
    
    if (len > 0)
    {
        m_message.resize(len);
        
        buffer.read_bytes(
            reinterpret_cast<char *>(&m_message[0]), m_message.size()
        );
    }
    
    len = buffer.read_var_int();
    
    if (len > 0)
    {
        m_signature.resize(len);
        
        buffer.read_bytes(
            reinterpret_cast<char *>(&m_signature[0]), m_signature.size()
        );
    }
    
    return true;
}
开发者ID:jaggedMiner,项目名称:vanillacoin,代码行数:26,代码来源:checkpoint_sync.cpp


示例3: encode

void zerotime_lock::encode(data_buffer & buffer)
{
    /**
     * Encode the version.
     */
    buffer.write_uint32(m_version);

    /**
     * Encode the transaction.
     */
    m_transaction.encode(buffer);

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

    /**
     * Encode the expiration.
     */
    buffer.write_uint64(m_expiration);

    /**
     * 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.
     */
}
开发者ID:tempbottle,项目名称:vanillacoin,代码行数:32,代码来源:zerotime_lock.cpp


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


示例5: decode

void transaction_out::decode(data_buffer & buffer)
{
    /**
     * Decode the value.
     */
    m_value = buffer.read_int64();
    
    /**
     * Read the var_int.
     */
    auto len = buffer.read_var_int();
    
    if (len > 0)
    {
        /**
         * Read the script.
         */
        auto bytes = buffer.read_bytes(len);
        
        /**
         * Insert the script.
         */
        m_script_public_key.insert(
            m_script_public_key.begin(), bytes.begin(), bytes.end()
        );
    }
}
开发者ID:jaggedMiner,项目名称:vanillacoin,代码行数:27,代码来源:transaction_out.cpp


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


示例7: encode

bool inventory_vector::encode(data_buffer & buffer)
{
    buffer.write_uint32(m_type);
    buffer.write_sha256(m_hash);
    
    return true;
}
开发者ID:jaggedMiner,项目名称:vanillacoin,代码行数:7,代码来源:inventory_vector.cpp


示例8: encode

void chainblender_join::encode(data_buffer & buffer)
{
    /**
     * Encode the version.
     */
    buffer.write_uint32(m_version);
    
    /**
     * The session id must be null for a cbjoin.
     */
    if (m_hash_session_id.is_empty() == false)
    {
        log_error(
            "ChainBlender join message has invalid hash session "
            "id = " << m_hash_session_id.to_string() << "."
        );
    }
    
    /**
     * Encode the session id.
     */
    buffer.write_sha256(m_hash_session_id);
    
    /**
     * Encode the denomination.
     */
    buffer.write_int64(m_denomination);
}
开发者ID:greenmo000,项目名称:vcash,代码行数:28,代码来源:chainblender_join.cpp


示例9:

offs_t cop420_disassembler::disassemble(std::ostream &stream, offs_t pc, const data_buffer &opcodes, const data_buffer &params)
{
	uint8_t opcode = opcodes.r8(pc);
	uint8_t next_opcode = opcodes.r8(pc+1);
	uint16_t address;
	uint32_t flags = 0;
	int bytes = 1;

	if ((opcode >= 0x80 && opcode <= 0xBE) || (opcode >= 0xC0 && opcode <= 0xFE))
	{
		int page = pc >> 6;

		if (page == 2 || page == 3) //JP pages 2,3
		{
			address = (uint16_t)((pc & 0x380) | (opcode & 0x7F));
			util::stream_format(stream, "JP %03X", address);
		}
		else
		{
			if ((opcode & 0xC0) == 0xC0) //JP other pages
			{
				address = (uint16_t)((pc & 0x3C0) | (opcode & 0x3F));
				util::stream_format(stream, "JP %03X", address);
			}
			else                    //JSRP
			{
				address = (uint16_t)(0x80 | (opcode & 0x3F));
				util::stream_format(stream, "JSRP %03X", address);
				flags = STEP_OVER;
			}
		}
	}
开发者ID:Dagarman,项目名称:mame,代码行数:32,代码来源:cop420ds.cpp


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


示例11: erase_begin

bool erase_begin(data_buffer& buffer, index123_type& index123)
{
  data_pointer ptr = buffer.begin();
  auto itr = index123.find( ptr.get_offset() /*static_cast<offset_t>( static_cast<size_t>(ptr) )*/);
  index123.erase(itr);
  buffer.deallocate(ptr, 1);
  return true;
}
开发者ID:dmitry-saprykin,项目名称:v-set,代码行数:8,代码来源:multiset_test_impl.cpp


示例12: encode

void hd_configuration::encode(data_buffer & buffer) const
{
    assert(m_id_key_master.digest().size() == ripemd160::digest_length);
    buffer.write_uint32(m_version);
    buffer.write_uint32(m_index);
    buffer.write_bytes(
        reinterpret_cast<const char *> (&m_id_key_master.digest()[0]),
        ripemd160::digest_length
    );
}
开发者ID:xCoreDev,项目名称:vcash,代码行数:10,代码来源:hd_configuration.cpp


示例13: data_buffer

            /**
             * Copy constructor
             * @param other The other data_buffer.
             */
			data_buffer(const data_buffer & other)
			    : m_read_ptr(0)
                , file_offset_(other.file_offset_)
                , file_(other.file_)
			{
                clear();
                
			    write_bytes(other.data(), other.size());
                
                m_read_ptr = m_data.size() > 0 ? &m_data[0] : 0;
			}
开发者ID:machado-rev,项目名称:vcash,代码行数:15,代码来源:data_buffer.hpp


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


示例15: encode

void checkpoint_sync::encode(data_buffer & buffer)
{
    buffer.write_var_int(m_message.size());
    buffer.write_bytes(
        reinterpret_cast<char *>(&m_message[0]), m_message.size()
    );
    
    buffer.write_var_int(m_signature.size());
    buffer.write_bytes(
        reinterpret_cast<char *>(&m_signature[0]), m_signature.size()
    );
}
开发者ID:jaggedMiner,项目名称:vanillacoin,代码行数:12,代码来源:checkpoint_sync.cpp


示例16: verify

bool incentive_vote::verify(data_buffer & buffer)
{
    auto ret = false;
    
    /**
     * Calculate the hash of the nonce hash.
     */
    auto digest = hash::sha256d(
        m_hash_nonce.digest(), sha256::digest_length
    );

    /**
     * Hash the encoded message buffer.
     */
    sha256 hash_value = sha256::from_digest(&digest[0]);
    
    /**
     * Read the signature.
     */
    auto signature_len = buffer.read_var_int();

    if (signature_len > 0)
    {
        m_signature.resize(signature_len);
        
        buffer.read_bytes(
            reinterpret_cast<char *>(&m_signature[0]), m_signature.size()
        );

        if (
            incentive::instance().verify(m_public_key, hash_value,
            m_signature) == true
            )
        {
            ret = true;
            
            log_debug(
                "Incentive vote verified value (" <<
                hash_value.to_string().substr(0, 8) << ")."
            );
        }
        else
        {
            log_error(
                "Incentive vote failed to verify value (" <<
                hash_value.to_string().substr(0, 8) << ")."
            );
        }
    }
    
    return ret;
}
开发者ID:machado-rev,项目名称:vcash,代码行数:52,代码来源:incentive_vote.cpp


示例17: param_dr_lit

offs_t capricorn_disassembler::param_dr_lit(std::ostream &stream, offs_t pc, const data_buffer &opcodes)
{
	stream << "DR,=";
	// Here we assume that multi-byte instructions operate on 2 bytes because we
	// have no way of knowing how many they are (the actual number of bytes is
	// dynamically determined by the value of DRP register at run-time)
	unsigned bytes = BIT(opcodes.r8(pc), 0) ? 2 : 1;

	for (unsigned i = 1; i <= bytes; i++) {
		util::stream_format(stream, "$%02x ", opcodes.r8(pc+i));
	}

	return bytes;
}
开发者ID:Dagarman,项目名称:mame,代码行数:14,代码来源:capricorn_dasm.cpp


示例18: dbt_key

bool db_tx::read(const data_buffer & key, T & value)
{
    if (m_Db == 0)
    {
        return false;
    }
    
    Dbt dbt_key(key.data(), static_cast<std::uint32_t> (key.size()));

    Dbt dbt_value;
    
    dbt_value.set_flags(DB_DBT_MALLOC);
    
    auto ret = m_Db->get(m_DbTxn, &dbt_key, &dbt_value, 0);
    
    std::memset(dbt_key.get_data(), 0, dbt_key.get_size());
    
    if (dbt_value.get_data() == 0)
    {
        return false;
    }
    
    try
    {
        /**
         * Allocate the data_buffer.
         */
        data_buffer buffer(
            static_cast<char *>(dbt_value.get_data()), dbt_value.get_size()
        );
        
        /**
         * Decode the value from the buffer.
         */
        value.decode(buffer);
    }
    catch (std::exception & e)
    {
        log_error("DB TX read failed, what = " << e.what() << ".");
        
        return false;
    }

    std::memset(dbt_value.get_data(), 0, dbt_value.get_size());
    
    free(dbt_value.get_data());
    
    return ret == 0;
}
开发者ID:jaggedMiner,项目名称:vanillacoin,代码行数:49,代码来源:db_tx.cpp


示例19: decode

bool alert::decode(data_buffer & buffer)
{
    auto len = buffer.read_var_int();
    
    if (len > 0)
    {
        m_message.resize(len);
        
        buffer.read_bytes(
            reinterpret_cast<char *>(&m_message[0]), m_message.size()
        );
    }
    
    len = buffer.read_var_int();
    
    if (len > 0)
    {
        m_signature.resize(len);
        
        buffer.read_bytes(
            reinterpret_cast<char *>(&m_signature[0]), m_signature.size()
        );
    }
    
    /**
     * If we have a message, decode it.
     */
    if (m_message.size() > 0)
    {
        /**
         * Allocate the message buffer.
         */
        data_buffer buffer_message;
        
        /**
         * Write the message into the buffer.
         */
        buffer_message.write_bytes(
            reinterpret_cast<const char *>(&m_message[0]), m_message.size()
        );
        
        /**
         * Decode the message.
         */
        alert_unsigned::decode(buffer_message);
    }
    
    return true;
}
开发者ID:greenmo000,项目名称:vcash,代码行数:49,代码来源:alert.cpp


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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ data_chunk类代码示例发布时间:2022-05-31
下一篇:
C++ dataPtr_Type类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap