import struct


def find_coordinator_ok(node_id, host, port):
    """
    Encode a successful FindCoordinatorResponse v0.
    """
    host_bytes = host.encode('ascii')
    return b"".join([  # FindCoordinator Response v0
        struct.pack('>h', 0),                # No error
        struct.pack('>i', node_id),        # Coordinator id
        struct.pack('>h', len(host_bytes)),  # The Coordinator host
        host_bytes,
        struct.pack('>i', port),             # The Coordinator port
    ])