Пример #1
0
bool block_transactions::from_data(uint32_t version, reader& source)
{
    reset();

    block_hash_ = source.read_hash();
    const auto count = source.read_size_little_endian();

    // Guard against potential for arbitrary memory allocation.
    if (count > max_block_size)
        source.invalidate();
    else
        transactions_.resize(count);

    // Order is required.
    for (auto& tx: transactions_)
        if (!tx.from_data(source, true))
            break;

    if (version < block_transactions::version_minimum)
        source.invalidate();

    if (!source)
        reset();

    return source;
}
Пример #2
0
bool send_compact::from_data(uint32_t version,
    reader& source)
{
    reset();

    const auto mode = source.read_byte();

    if (mode > 1)
        source.invalidate();

    high_bandwidth_mode_ = (mode == 1);
    this->version_ = source.read_8_bytes_little_endian();

    if (version < send_compact::version_minimum)
        source.invalidate();

    if (!source)
        reset();

    return source;
}
Пример #3
0
bool header::from_data(uint32_t version, reader& source)
{
    if (!chain::header::from_data(source))
        return false;

    // The header message must trail a zero byte (yes, it's stoopid).
    // bitcoin.org/en/developer-reference#headers
    if (version != version::level::canonical && source.read_byte() != 0x00)
        source.invalidate();

    if (!source)
        reset();

    return source;
}
Пример #4
0
bool filter_clear::from_data(uint32_t version, reader& source)
{
    reset();

    // Initialize as valid from deserialization.
    insufficient_version_ = false;

    if (version < filter_clear::version_minimum)
        source.invalidate();

    if (!source)
        reset();

    return source;
}