您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ BITCOIN_ASSERT函数代码示例

51自学网 2021-06-01 19:50:34
  C++
这篇教程C++ BITCOIN_ASSERT函数代码示例写得很实用,希望能帮到您。

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

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

示例1: it

uint32_t leveldb_common::find_last_block_height(){    leveldb_iterator it(db_.block->NewIterator(leveldb::ReadOptions()));    it->SeekToLast();    if (!it->Valid() || !it->status().ok())        return std::numeric_limits<uint32_t>::max();    BITCOIN_ASSERT(it->key().size() == 4);    return recreate_height(it->key());}
开发者ID:ralphtheninja,项目名称:libbitcoin,代码行数:9,


示例2: BITCOIN_ASSERT

bool leveldb_common::duplicate_exists(const hash_digest& tx_hash,    uint32_t block_height, uint32_t tx_index){    leveldb_tx_info tx;    if (!get_transaction(tx, tx_hash, false, false))        return false;    BITCOIN_ASSERT(block_height == 91842 || block_height == 91880);    return true;}
开发者ID:ralphtheninja,项目名称:libbitcoin,代码行数:9,


示例3: ostream

data_chunk block::to_data() const{    data_chunk data;    data_sink ostream(data);    to_data(ostream);    ostream.flush();    BITCOIN_ASSERT(data.size() == serialized_size());    return data;}
开发者ID:zauguin,项目名称:libbitcoin,代码行数:9,


示例4: wrap_fetch_history_args

void wrap_fetch_history_args(data_chunk& data,    const payment_address& address, size_t from_height){    data.resize(1 + short_hash_size + 4);    auto serial = make_serializer(data.begin());    serial.write_byte(address.version());    serial.write_short_hash(address.hash());    serial.write_4_bytes(from_height);    BITCOIN_ASSERT(serial.iterator() == data.end());}
开发者ID:grazcoin,项目名称:obelisk,代码行数:10,


示例5: unpack_char

		void unpack_char(data_chunk& data, int carry)		{			for (auto it = data.rbegin(); it != data.rend(); it++)			{				carry += 58 * (*it);				*it = carry % 256;				carry /= 256;			}			BITCOIN_ASSERT(carry == 0);		}
开发者ID:ballisticwhisper,项目名称:decentralised,代码行数:10,


示例6: BITCOIN_ASSERT

// Write the count value to the first 32 bits of the file after the header.void record_manager::write_count(){    BITCOIN_ASSERT(header_size_ + sizeof(array_index) <= file_.size());    // The accessor must remain in scope until the end of the block.    auto memory = file_.access();    auto payload_size_address = REMAP_ADDRESS(memory) + header_size_;    auto serial = make_serializer(payload_size_address);    serial.write_little_endian(record_count_);}
开发者ID:liunix1982,项目名称:libbitcoin-database,代码行数:11,


示例7: BITCOIN_ASSERT

uint64_t leveldb_validate_block::actual_timespan(const uint64_t interval){    // Warning: conversion from 'uint64_t' to 'uint32_t',     // possible loss of data in fetch_block parameterization.    BITCOIN_ASSERT(interval <= UINT32_MAX);    // height - interval and height - 1, return time difference    return fetch_block(height_ - 1).timestamp -        fetch_block(height_ - (uint32_t)interval).timestamp;}
开发者ID:lclc,项目名称:libbitcoin,代码行数:10,


示例8: raw_block_data

bool leveldb_common::save_block(    uint32_t height, const block_type& serial_block){    leveldb_transaction_batch batch;    // Write block header + tx hashes    data_chunk raw_block_data(        80 + 4 + serial_block.transactions.size() * hash_digest_size);    // Downcast to base header type so serializer selects that.    auto header_end = satoshi_save(        serial_block.header, raw_block_data.begin());    BITCOIN_ASSERT(std::distance(raw_block_data.begin(), header_end) == 80);    auto serial_hashes = make_serializer(header_end);    // Write the number of transactions...    serial_hashes.write_4_bytes(serial_block.transactions.size());    // ... And now the tx themselves.    for (uint32_t tx_index = 0;        tx_index < serial_block.transactions.size(); ++tx_index)    {        const transaction_type& block_tx =            serial_block.transactions[tx_index];        const hash_digest& tx_hash = hash_transaction(block_tx);        if (!save_transaction(batch, height, tx_index, tx_hash, block_tx))        {            log_fatal(LOG_BLOCKCHAIN) << "Could not save transaction";            return false;        }        serial_hashes.write_hash(tx_hash);    }    BITCOIN_ASSERT(serial_hashes.iterator() ==        raw_block_data.begin() + 80 + 4 +            serial_block.transactions.size() * hash_digest_size);    data_chunk raw_height = uncast_type(height);    hash_digest block_hash = hash_block_header(serial_block.header);    // Write block header    batch.block.Put(slice(raw_height), slice(raw_block_data));    batch.block_hash.Put(slice_block_hash(block_hash), slice(raw_height));    // Execute batches.    db_.write(batch);    // Sync stealth database.    db_stealth_->sync(height);    return true;}
开发者ID:kaostao,项目名称:libbitcoin,代码行数:42,


示例9: pack_value

		void pack_value(data_chunk& indexes, int carry)		{			// Apply "b58 = b58 * 256 + ch".			for (auto it = indexes.rbegin(); it != indexes.rend(); ++it)			{				carry += 256 * (*it);				*it = carry % 58;				carry /= 58;			}			BITCOIN_ASSERT(carry == 0);		}
开发者ID:ballisticwhisper,项目名称:decentralised,代码行数:11,


示例10: addr_key_checksum

uint32_t addr_key_checksum(const output_point& outpoint){    data_chunk chksum_data(hash_digest_size + 4);    auto serial = make_serializer(chksum_data.begin());    serial.write_hash(outpoint.hash);    serial.write_4_bytes(outpoint.index);    BITCOIN_ASSERT(        std::distance(chksum_data.begin(), serial.iterator()) ==        hash_digest_size + 4);    return generate_sha256_checksum(chksum_data);}
开发者ID:ralphtheninja,项目名称:libbitcoin,代码行数:11,


示例11: serialized_size

data_chunk alert::to_data(uint32_t version) const{    data_chunk data;    const auto size = serialized_size(version);    data.reserve(size);    data_sink ostream(data);    to_data(version, ostream);    ostream.flush();    BITCOIN_ASSERT(data.size() == size);    return data;}
开发者ID:RojavaCrypto,项目名称:libbitcoin,代码行数:11,


示例12: do_relay

 void do_relay(Args... params) {     registry_stack notify_copy = registry_;     registry_ = registry_stack();     while (!notify_copy.empty())     {         notify_copy.top()(params...);         notify_copy.pop();     }     BITCOIN_ASSERT(notify_copy.empty()); }
开发者ID:bitkevin,项目名称:libbitcoin,代码行数:11,


示例13: BITCOIN_ASSERT

		bool elliptic_curve_key::verify(hash_digest hash, const data_chunk& signature)		{			BITCOIN_ASSERT(key_ != nullptr);			// SSL likes a reversed hash			std::reverse(hash.begin(), hash.end());			// -1 = error, 0 = bad sig, 1 = good			if (ECDSA_verify(0, hash.data(), hash.size(),				signature.data(), signature.size(), key_) == 1)				return true;			return false;		}
开发者ID:ballisticwhisper,项目名称:decentralised,代码行数:11,


示例14: serialized_size

data_chunk point::to_data(bool wire) const{    data_chunk data;    const auto size = serialized_size(wire);    data.reserve(size);    data_sink ostream(data);    to_data(ostream, wire);    ostream.flush();    BITCOIN_ASSERT(data.size() == size);    return data;}
开发者ID:RojavaCrypto,项目名称:libbitcoin,代码行数:11,


示例15: bc_hash_digest_encode_hex

char* bc_hash_digest_encode_hex(bc_hash_digest_t* self){    BITCOIN_ASSERT(sizeof(char) == 1);    char* result = (char*)malloc(BC_HASH_DIGEST_LENGTH * 2 + 1);    bc::hash_digest tmp_hash;    std::copy(self, self + BC_HASH_DIGEST_LENGTH, tmp_hash.begin());    std::string repr = bc::encode_hex(tmp_hash);    std::copy(repr.begin(), repr.end(), result);    result[BC_HASH_DIGEST_LENGTH * 2] = '/0';    return result;}
开发者ID:jestin,项目名称:libbitcoin-c-wrapper,代码行数:11,


示例16: create_address_key

data_chunk create_address_key(    const payment_address& address, const output_point& outpoint){    data_chunk result(1 + short_hash_size + 8);    auto serial = make_serializer(result.begin());    serial.write_byte(address.version());    serial.write_short_hash(address.hash());    serial.write_8_bytes(addr_key_checksum(outpoint));    BITCOIN_ASSERT(serial.iterator() == result.end());    return result;}
开发者ID:kaostao,项目名称:libbitcoin,代码行数:11,


示例17: process_stealth_output_info

bool process_stealth_output_info(const transaction_output_type& output,    data_chunk& stealth_data_store){    // Return true when we want the main loop to skip past this    // output and not process it any further.    if (output.script.type() != payment_type::stealth_info)        return false;    BITCOIN_ASSERT(output.script.operations().size() == 2);    stealth_data_store = output.script.operations()[1].data;    return true;}
开发者ID:kaostao,项目名称:libbitcoin,代码行数:11,


示例18: BITCOIN_ASSERT

uint64_t leveldb_validate_block::median_time_past(){    // read last 11 block times into array and select median value    std::vector<uint64_t> times;    for (int i = height_ - 1; i >= 0 && i >= (int)height_ - 11; --i)        times.push_back(fetch_block(i).timestamp);    BITCOIN_ASSERT(        (height_ < 11 && times.size() == height_) || times.size() == 11);    std::sort(times.begin(), times.end());    return times[times.size() / 2];}
开发者ID:RagnarDanneskjold,项目名称:libbitcoin,代码行数:11,


示例19: addr_key_checksum

uint64_t addr_key_checksum(const output_point& outpoint){    data_chunk checksum_data(hash_digest_size + 4);    auto serial = make_serializer(checksum_data.begin());    serial.write_hash(outpoint.hash);    serial.write_4_bytes(outpoint.index);    BITCOIN_ASSERT(serial.iterator() == checksum_data.end());    hash_digest hash = generate_sha256_hash(checksum_data);    data_chunk raw_checksum(hash.begin(), hash.begin() + 8);    return cast_chunk<uint64_t>(raw_checksum);}
开发者ID:kaostao,项目名称:libbitcoin,代码行数:11,


示例20: extend_data

		std::string payment_address::encoded() const		{			data_chunk unencoded_address;			unencoded_address.reserve(25);			// Type, Hash, Checksum doth make thy address			unencoded_address.push_back(version_);			extend_data(unencoded_address, hash_);			append_checksum(unencoded_address);			BITCOIN_ASSERT(unencoded_address.size() == 25);			return encode_base58(unencoded_address);		}
开发者ID:ballisticwhisper,项目名称:decentralised,代码行数:11,


示例21: ALLOCATE_WRITE

void record_manager::set_count(const array_index value){    // Critical Section    ///////////////////////////////////////////////////////////////////////////    ALLOCATE_WRITE(mutex_);    BITCOIN_ASSERT(value <= record_count_);    record_count_ = value;    ///////////////////////////////////////////////////////////////////////////}
开发者ID:liunix1982,项目名称:libbitcoin-database,代码行数:11,


示例22: extract_input_address

bool extract_input_address(    payment_address& address, const script& input_script){    const operation_stack& ops = input_script.operations();    if (!input_has_pubkey(ops))        return false;    BITCOIN_ASSERT(ops.size() == 2);    const data_chunk& pubkey = ops[1].data;    if (!set_public_key(address, pubkey))        return false;    return true;}
开发者ID:vbuterin,项目名称:libbitcoin,代码行数:12,


示例23: fetch_proto_transaction

bool bdb_common::dupli_save(txn_guard_ptr txn, const hash_digest& tx_hash,    uint32_t block_depth, uint32_t tx_index){    protobuf::Transaction proto_tx = fetch_proto_transaction(txn, tx_hash);    if (!proto_tx.IsInitialized())        return false;    BITCOIN_ASSERT(block_depth == 91842 || block_depth == 91880);    protobuf::Transaction::BlockPointer* parent = proto_tx.add_parent();    parent->set_depth(block_depth);    parent->set_index(tx_index);    return rewrite_transaction(txn, tx_hash, proto_tx);}
开发者ID:da2ce7,项目名称:libbitcoin,代码行数:12,


示例24: BITCOIN_ASSERT

bool leveldb_common::deserialize_block(leveldb_block_info& blk_info,    const std::string& raw_data, bool read_header, bool read_tx_hashes){    // Read the header (if neccessary).    // There is always at least one tx in a block.    BITCOIN_ASSERT(raw_data.size() >= 80 + 4 + hash_digest_size);    BITCOIN_ASSERT((raw_data.size() - 84) % hash_digest_size == 0);    if (read_header)        satoshi_load(raw_data.begin(), raw_data.begin() + 80, blk_info.header);    if (!read_tx_hashes)        return true;    // Read the tx hashes for this block (if neccessary).    auto deserial = make_deserializer(raw_data.begin() + 80, raw_data.end());    uint32_t tx_count = deserial.read_4_bytes();    for (size_t i = 0; i < tx_count; ++i)    {        const hash_digest& tx_hash = deserial.read_hash();        blk_info.tx_hashes.push_back(tx_hash);    }    return true;}
开发者ID:kaostao,项目名称:libbitcoin,代码行数:21,


示例25: height_

stealth_record::stealth_record(size_t height, uint32_t prefix,    const hash_digest& ephemeral_public_key,    const short_hash& public_key_hash, const hash_digest& transaction_hash)  : height_(static_cast<uint32_t>(height)),    prefix_(prefix),    unsigned_ephemeral_(ephemeral_public_key),    public_key_hash_(public_key_hash),    transaction_hash_(transaction_hash){    // This class is used internal to the store, parameters presumed valid.    BITCOIN_ASSERT(height <= max_uint32);}
开发者ID:libbitcoin,项目名称:libbitcoin,代码行数:12,


示例26: receive_transaction_result

void receive_transaction_result(const data_chunk& data,    blockchain::fetch_handler_transaction handle_fetch){    std::error_code ec;    auto deserial = make_deserializer(data.begin(), data.end());    if (!read_error_code(deserial, data.size(), ec))        return;    BITCOIN_ASSERT(deserial.iterator() == data.begin() + 4);    transaction_type tx;    satoshi_load(deserial.iterator(), data.end(), tx);    handle_fetch(ec, tx);}
开发者ID:grazcoin,项目名称:obelisk,代码行数:12,


示例27: select_outputs

select_outputs_result select_outputs(    output_info_list unspent, uint64_t min_value,    select_outputs_algorithm DEBUG_ONLY(algorithm)){    // Just one default implementation for now.    // Consider a switch case with greedy_select_outputs(min_value) .etc    // if this is ever extended with more algorithms.    BITCOIN_ASSERT(algorithm == select_outputs_algorithm::greedy);    // Fail if empty.    if (unspent.empty())        return select_outputs_result();    auto lesser_begin = unspent.begin();    auto lesser_end = std::partition(unspent.begin(), unspent.end(),        [min_value](const output_info_type& out_info)        {            return out_info.value < min_value;        });    auto greater_begin = lesser_end;    auto greater_end = unspent.end();    auto min_greater = std::min_element(greater_begin, greater_end,        [](const output_info_type& info_a, const output_info_type& info_b)        {            return info_a.value < info_b.value;        });    select_outputs_result result;    if (min_greater != greater_end)    {        result.change = min_greater->value - min_value;        result.points.push_back(min_greater->point);        return result;    }    // Not found in greaters. Try several lessers instead.    // Rearrange them from biggest to smallest. We want to use the least    // amount of inputs as possible.    std::sort(lesser_begin, lesser_end,        [](const output_info_type& info_a, const output_info_type& info_b)        {            return info_a.value > info_b.value;        });    uint64_t accum = 0;    for (auto it = lesser_begin; it != lesser_end; ++it)    {        result.points.push_back(it->point);        accum += it->value;        if (accum >= min_value)        {            result.change = accum - min_value;            return result;        }    }    return select_outputs_result();}
开发者ID:Mrkebubun,项目名称:libbitcoin,代码行数:52,


示例28: create_mnemonic

word_list create_mnemonic(data_slice entropy, const dictionary &lexicon){    if ((entropy.size() % mnemonic_seed_multiple) != 0)        return word_list();    const size_t entropy_bits = (entropy.size() * byte_bits);    const size_t check_bits = (entropy_bits / entropy_bit_divisor);    const size_t total_bits = (entropy_bits + check_bits);    const size_t word_count = (total_bits / bits_per_word);    BITCOIN_ASSERT((total_bits % bits_per_word) == 0);    BITCOIN_ASSERT((word_count % mnemonic_word_multiple) == 0);    const auto data = build_chunk({entropy, sha256_hash(entropy)});    size_t bit = 0;    word_list words;    for (size_t word = 0; word < word_count; word++)    {        size_t position = 0;        for (size_t loop = 0; loop < bits_per_word; loop++)        {            bit = (word * bits_per_word + loop);            position <<= 1;            const auto byte = bit / byte_bits;            if ((data[byte] & bip39_shift(bit)) > 0)                position++;        }        BITCOIN_ASSERT(position < dictionary_size);        words.push_back(lexicon[position]);    }    BITCOIN_ASSERT(words.size() == ((bit + 1) / bits_per_word));    return words;}
开发者ID:GeopaymeEE,项目名称:libbitcoin,代码行数:39,


示例29: BITCOIN_ASSERT

hash_number simple_chain_impl::sum_difficulty(size_t begin_index){    hash_number total_work = 0;    const auto last_height = interface_.blocks.last_height();    BITCOIN_ASSERT(last_height != block_database::null_height);    for (size_t index = begin_index; index <= last_height; ++index)    {        const auto bits = interface_.blocks.get(index).header().bits;        total_work += block_work(bits);    }    return total_work;}
开发者ID:lastcanal,项目名称:libbitcoin-blockchain,代码行数:13,


示例30: slice

bool leveldb_common::get_transaction(leveldb_tx_info& tx_info,    const hash_digest& tx_hash, bool read_parent, bool read_tx){    // First we try to read the bytes from the database.    std::string value;    leveldb::Status status = db_.tx->Get(        leveldb::ReadOptions(), slice(tx_hash), &value);    if (status.IsNotFound())        return false;    else if (!status.ok())    {        log_fatal(LOG_BLOCKCHAIN) << "get_transaction("            << tx_hash << "): " << status.ToString();        return false;    }    // Read the parent block height and our index in that block (if neccessary).    BITCOIN_ASSERT(value.size() > 8);    if (read_parent)    {        auto deserial = make_deserializer(value.begin(), value.begin() + 8);        tx_info.height = deserial.read_4_bytes();        tx_info.index = deserial.read_4_bytes();    }    if (!read_tx)        return true;    // Read the actual transaction (if neccessary).    try    {        BITCOIN_ASSERT(value.size() > 8);        satoshi_load(value.begin() + 8, value.end(), tx_info.tx);    }    catch (end_of_stream)    {        return false;    }    BITCOIN_ASSERT(satoshi_raw_size(tx_info.tx) + 8 == value.size());    BITCOIN_ASSERT(hash_transaction(tx_info.tx) == tx_hash);    return true;}
开发者ID:kaostao,项目名称:libbitcoin,代码行数:39,



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


C++ BITCSET函数代码示例
C++ BITBAND_Peripheral函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。