Exemplo n.º 1
0
void transaction_database::store(size_t height, size_t index,
    const chain::transaction& tx)
{
    // Write block data.
    const hash_digest key = tx.hash();
    const size_t value_size = 4 + 4 + tx.serialized_size();
    auto write = [&height, &index, &tx](uint8_t* data)
    {
        auto serial = make_serializer(data);
        serial.write_4_bytes_little_endian(height);
        serial.write_4_bytes_little_endian(index);
        data_chunk tx_data = tx.to_data();
        serial.write_data(tx_data);
    };
    map_.store(key, write, value_size);
}
Exemplo n.º 2
0
void protocol_total_connections(server_node& node,
    const incoming_message& request, queue_send_callback queue_send)
{
    BITCOIN_ASSERT(node.protocol().total_connections() <= max_uint32);
    const auto total_connections32 = static_cast<uint32_t>(
        node.protocol().total_connections());
    data_chunk result(8);
    auto serial = make_serializer(result.begin());
    write_error_code(serial, std::error_code());
    serial.write_4_bytes_little_endian(total_connections32);
    BITCOIN_ASSERT(serial.iterator() == result.end());

    log_debug(LOG_REQUEST)
        << "protocol.total_connections() finished. Sending response.";

    outgoing_message response(request, result);
    queue_send(response);
}