本文整理汇总了C++中BITCOIN_ASSERT函数的典型用法代码示例。如果您正苦于以下问题:C++ BITCOIN_ASSERT函数的具体用法?C++ BITCOIN_ASSERT怎么用?C++ BITCOIN_ASSERT使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了BITCOIN_ASSERT函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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,代码来源:leveldb_common.cpp
示例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,代码来源:leveldb_common.cpp
示例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,代码来源:block.cpp
示例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,代码来源:fetch_x.cpp
示例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,代码来源:base58.cpp
示例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,代码来源:record_manager.cpp
示例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,代码来源:leveldb_validate_block.cpp
示例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,代码来源:leveldb_common.cpp
示例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,代码来源:base58.cpp
示例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,代码来源:leveldb_common.cpp
示例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,代码来源:alert.cpp
示例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,代码来源:subscriber.hpp
示例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,代码来源:elliptic_curve_key.cpp
示例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,代码来源:point.cpp
示例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,代码来源:core.cpp
示例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,代码来源:leveldb_common.cpp
示例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,代码来源:leveldb_common.cpp
示例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,代码来源:leveldb_validate_block.cpp
示例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,代码来源:leveldb_common.cpp
示例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,代码来源:address.cpp
注:本文中的BITCOIN_ASSERT函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论