本文整理汇总了C++中transaction::is_coinbase方法的典型用法代码示例。如果您正苦于以下问题:C++ transaction::is_coinbase方法的具体用法?C++ transaction::is_coinbase怎么用?C++ transaction::is_coinbase使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类transaction
的用法示例。
在下文中一共展示了transaction::is_coinbase方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: connect_input
bool validate_transaction::connect_input(const transaction& tx,
size_t current_input, const transaction& previous_tx,
size_t parent_height, size_t last_block_height, uint64_t& value_in)
{
const auto& input = tx.inputs[current_input];
const auto& previous_outpoint = tx.inputs[current_input].previous_output;
if (previous_outpoint.index >= previous_tx.outputs.size())
return false;
const auto& previous_output = previous_tx.outputs[previous_outpoint.index];
const auto output_value = previous_output.value;
if (output_value > max_money())
return false;
if (previous_tx.is_coinbase())
{
const auto height_difference = last_block_height - parent_height;
if (height_difference < coinbase_maturity)
return false;
}
if (!check_consensus(previous_output.script, tx, current_input))
return false;
value_in += output_value;
return value_in <= max_money();
}
示例2: add
void unspent_outputs::add(const transaction& tx, size_t height,
uint32_t median_time_past, bool confirmed)
{
if (disabled() || tx.outputs().empty())
return;
if (tx.is_coinbase())
{
LOG_DEBUG(LOG_DATABASE)
<< "Output cache hit rate: " << hit_rate() << ", size: " << size();
}
// Critical Section
///////////////////////////////////////////////////////////////////////////
unique_lock lock(mutex_);
// It's been a long time since the last restart (~16 years).
if (sequence_ == max_uint32)
unspent_.clear();
// Remove the oldest entry if the buffer is at capacity.
if (unspent_.size() >= capacity_)
unspent_.right.erase(unspent_.right.begin());
// TODO: promote the unconfirmed tx cache instead of replacing it.
// A confirmed tx may replace the same unconfirmed tx here.
unspent_.insert(
{
unspent_transaction{ tx, height, median_time_past, confirmed },
++sequence_
});
///////////////////////////////////////////////////////////////////////////
}
示例3: check_transaction
code validate_transaction::check_transaction(const transaction& tx)
{
if (tx.inputs.empty() || tx.outputs.empty())
return error::empty_transaction;
if (tx.serialized_size() > max_transaction_size)
return error::size_limits;
// Check for negative or overflow output values
uint64_t total_output_value = 0;
for (const auto& output: tx.outputs)
{
if (output.value > max_money())
return error::output_value_overflow;
total_output_value += output.value;
if (total_output_value > max_money())
return error::output_value_overflow;
}
if (tx.is_coinbase())
{
const auto& coinbase_script = tx.inputs[0].script;
const auto coinbase_size = coinbase_script.serialized_size(false);
if (coinbase_size < 2 || coinbase_size > 100)
return error::invalid_coinbase_script_size;
}
else
{
for (const auto& input: tx.inputs)
if (input.previous_output.is_null())
return error::previous_output_null;
}
return error::success;
}