Bitcoin full node and query server

Dec 5, 2019

View in context in the libbitcoin Slack #general mirror.

N
narodnik19:43
void blockchain::history_fetched(const code& ec,
    const history_compact::list& history, const message& request,
    send_handler handler)
{
    static constexpr size_t row_size = sizeof(uint8_t) + point_size +
        sizeof(uint32_t) + sizeof(uint64_t);

    data_chunk result(code_size + row_size * history.size());
    auto serial = make_unsafe_serializer(result.begin());
    serial.write_error_code(ec);

    // TODO: add serialization to history_compact.
    for (const auto& row: history)
    {
        BITCOIN_ASSERT(row.height <= max_uint32);
        serial.write_byte(static_cast<uint8_t>(row.kind));
        serial.write_bytes(row.point.to_data());
        serial.write_4_bytes_little_endian(row.height);
        serial.write_8_bytes_little_endian(row.value);
    }

    handler(message(request, std::move(result)));
}