Exemplo n.º 1
0
bool point::from_data(reader& source, bool wire)
{
    reset();

    valid_ = true;
    hash_ = source.read_hash();

    if (wire)
    {
        index_ = source.read_4_bytes_little_endian();
    }
    else
    {
        index_ = source.read_2_bytes_little_endian();

        // Convert 16 bit sentinel to 32 bit sentinel.
        if (index_ == max_uint16)
            index_ = null_index;
    }

    if (!source)
        reset();

    return source;
}
Exemplo n.º 2
0
// Avoid point reuse due to affect on store tx serialization.
bool payment_record::from_data(reader& source, bool wire)
{
    valid_ = true;
    output_ = (source.read_byte() == 1);

    if (wire)
    {
        height_ = source.read_4_bytes_little_endian();
        link_ = unlinked;
        hash_ = source.read_hash();
        index_ = source.read_4_bytes_little_endian();
    }
    else
    {
        height_ = 0;
        link_ = source.read_8_bytes_little_endian();
        hash_ = null_hash;
        index_ = source.read_2_bytes_little_endian();

        // Convert 16 bit sentinel to 32 bit sentinel.
        if (index_ == max_uint16)
            index_ = point::null_index;
    }

    data_ = source.read_8_bytes_little_endian();

    if (!source)
        reset();

    return source;
}
Exemplo n.º 3
0
bool operation::read_opcode_data_size(uint32_t& count, opcode code,
    uint8_t raw_byte, reader& source)
{
    switch (code)
    {
        case opcode::special:
            count = raw_byte;
            return true;
        case opcode::pushdata1:
            count = source.read_byte();
            return true;
        case opcode::pushdata2:
            count = source.read_2_bytes_little_endian();
            return true;
        case opcode::pushdata4:
            count = source.read_4_bytes_little_endian();
            return true;
        default:
            return false;
    }
}