getNextValidatorPID returns the next pid with the verify type using roundRobin LB
(key types.VerifyType)
| 458 | |
| 459 | // getNextValidatorPID returns the next pid with the verify type using roundRobin LB |
| 460 | func (s *TXPoolServer) getNextValidatorPID(key types.VerifyType) *actor.PID { |
| 461 | s.validators.Lock() |
| 462 | defer s.validators.Unlock() |
| 463 | |
| 464 | length := len(s.validators.entries[key]) |
| 465 | if length == 0 { |
| 466 | return nil |
| 467 | } |
| 468 | |
| 469 | entries := s.validators.entries[key] |
| 470 | lastIdx := s.validators.state.state[key] |
| 471 | next := (lastIdx + 1) % length |
| 472 | s.validators.state.state[key] = next |
| 473 | return entries[next].Sender |
| 474 | } |
| 475 | |
| 476 | // Stop stops server and workers. |
| 477 | func (s *TXPoolServer) Stop() { |