retransmittable.go 799 B

12345678910111213141516171819202122232425262728293031323334
  1. package ackhandler
  2. import "github.com/lucas-clemente/quic-go/internal/wire"
  3. // Returns a new slice with all non-retransmittable frames deleted.
  4. func stripNonRetransmittableFrames(fs []wire.Frame) []wire.Frame {
  5. res := make([]wire.Frame, 0, len(fs))
  6. for _, f := range fs {
  7. if IsFrameRetransmittable(f) {
  8. res = append(res, f)
  9. }
  10. }
  11. return res
  12. }
  13. // IsFrameRetransmittable returns true if the frame should be retransmitted.
  14. func IsFrameRetransmittable(f wire.Frame) bool {
  15. switch f.(type) {
  16. case *wire.AckFrame:
  17. return false
  18. default:
  19. return true
  20. }
  21. }
  22. // HasRetransmittableFrames returns true if at least one frame is retransmittable.
  23. func HasRetransmittableFrames(fs []wire.Frame) bool {
  24. for _, f := range fs {
  25. if IsFrameRetransmittable(f) {
  26. return true
  27. }
  28. }
  29. return false
  30. }