示例#1
0
// Optimize reads by short-circuiting what is unnecessary.
// Invalid returns are conflated with skipped, but are store only.
bool stealth_record::from_data(reader& source, size_t start_height,
    const binary& filter)
{
    height_ = source.read_4_bytes_little_endian();

    if (height_ < start_height)
    {
        reset();
        source.skip(serialized_size(false) - sizeof(uint32_t));
        return false;
    }

    prefix_ = source.read_4_bytes_little_endian();

    if (!filter.is_prefix_of(prefix_))
    {
        reset();
        source.skip(serialized_size(false) - 2 * sizeof(uint32_t));
        return false;
    }

    unsigned_ephemeral_ = source.read_hash();
    public_key_hash_ = source.read_short_hash();
    transaction_hash_ = source.read_hash();

    if (!source)
        reset();

    return source;
}
示例#2
0
bool stealth_record::from_data(reader& source, bool wire)
{
    if (!wire)
        return from_data(source, 0, {});

    reset();
    unsigned_ephemeral_ = source.read_hash();
    public_key_hash_ = source.read_short_hash();
    transaction_hash_ = source.read_hash();

    if (!source)
        reset();

    return source;
}