def dump_to_rsb(params: dict, times: np.ndarray, data: np.ndarray) -> bytes:
    """Сохранение данных в формате rsb.

    @params -- параметры набора
    @times -- абсолютные времена блоков в наносекундах
    @data -- данные блоков (block_num, block_size)

    @return -- сериализованные данные

    """
    assert isinstance(times, np.ndarray)
    assert times.ndim == 1
    assert isinstance(data, np.ndarray)
    assert data.ndim == 2
    assert len(data) == len(times)

    params['b_size'] = data.shape[1]
    params['events_num'] = data.shape[0]

    start = int(times.min() * 1e-9)
    end = int(times.max() * 1e-9)

    if 'start_time' not in params:
        params['start_time'] = datetime.fromtimestamp(start).isoformat()

    if 'end_time' not in params:
        params['end_time'] = datetime.fromtimestamp(end).isoformat()

    text_header = bytearray(5120)
    text = serialise_to_rsh(params).encode('cp1251')
    text_header[:len(text)] = text

    params['text_header_size'] = len(text)

    binary_header = serialize_to_rsb(params)

    bin_data = b''

    ch_num = params['channel_number']
    ev_size = params['b_size']
    for i, event_data in enumerate(data):
        event = bytearray(
            np.zeros(96 + 2 * ch_num * ev_size, np.byte).tostring())
        text_hdr = datetime.fromtimestamp(int(times[i] * 10e-9)).isoformat()

        event[:len(text_hdr)] = text_hdr.encode('cp1251')
        event[64:68] = struct.pack('I', i)
        event[72:80] = struct.pack('Q', int(times[i] * 10e-9))
        event[80:88] = struct.pack('Q', int(times[i]))

        event[96:] = event_data.astype(np.int16).tostring()
        bin_data += event

    return bytes(text_header + binary_header + bin_data)