github.com/psiphon-labs/psiphon-tunnel-core@v2.0.28+incompatible/psiphon/common/quic/gquic-go/internal/ackhandler/retransmittable.go (about)

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