Exemplo n.º 1
0
 data_chunk read_data(uint64_t n_bytes)
 {
     check_distance(iter_, end_, n_bytes);
     data_chunk raw_bytes(n_bytes);
     for (uint64_t i = 0; i < n_bytes; ++i)
         raw_bytes[i] = read_byte();
     return raw_bytes;
 }
Exemplo n.º 2
0
data_chunk istream_reader::read_data(size_t size)
{
    data_chunk raw_bytes(size);

    if (size > 0)
    {
        stream_.read(reinterpret_cast<char*>(raw_bytes.data()), size);
        auto size = stream_.gcount();
        BITCOIN_ASSERT(size <= bc::max_size_t);
        const auto read_size = static_cast<size_t>(size);

        if (size != read_size)
//          throw std::ios_base::failure(
//              "read_data failed to read requested number of bytes");
            raw_bytes.resize(read_size);
    }

    return raw_bytes;
}