TestMultipleKeys handles a one-off validation test for multiple keys.
(group *models.Group, keysText string)
| 313 | |
| 314 | // TestMultipleKeys handles a one-off validation test for multiple keys. |
| 315 | func (s *KeyService) TestMultipleKeys(group *models.Group, keysText string) ([]keypool.KeyTestResult, error) { |
| 316 | keysToTest := s.ParseKeysFromText(keysText) |
| 317 | if len(keysToTest) > maxRequestKeys { |
| 318 | return nil, fmt.Errorf("batch size exceeds the limit of %d keys, got %d", maxRequestKeys, len(keysToTest)) |
| 319 | } |
| 320 | if len(keysToTest) == 0 { |
| 321 | return nil, fmt.Errorf("no valid keys found in the input text") |
| 322 | } |
| 323 | |
| 324 | var allResults []keypool.KeyTestResult |
| 325 | for i := 0; i < len(keysToTest); i += chunkSize { |
| 326 | end := i + chunkSize |
| 327 | if end > len(keysToTest) { |
| 328 | end = len(keysToTest) |
| 329 | } |
| 330 | chunk := keysToTest[i:end] |
| 331 | results, err := s.KeyValidator.TestMultipleKeys(group, chunk) |
| 332 | if err != nil { |
| 333 | return nil, err |
| 334 | } |
| 335 | allResults = append(allResults, results...) |
| 336 | } |
| 337 | |
| 338 | return allResults, nil |
| 339 | } |
| 340 | |
| 341 | // StreamKeysToWriter fetches keys from the database in batches and writes them to the provided writer. |
| 342 | func (s *KeyService) StreamKeysToWriter(groupID uint, statusFilter string, writer io.Writer) error { |
nothing calls this directly
no test coverage detected