本文整理匯總了C++中BITCOIN_ASSERT函數的典型用法代碼示例。如果您正苦於以下問題:C++ BITCOIN_ASSERT函數的具體用法?C++ BITCOIN_ASSERT怎麽用?C++ BITCOIN_ASSERT使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了BITCOIN_ASSERT函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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());
}
示例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;
}
示例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;
}
示例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());
}
示例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);
}
示例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_);
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例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());
}
示例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;
}
示例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;
}
示例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;
}