// UpdateHighestReceived updates the highestReceived value, if the offset is higher.
UpdateHighestReceived updates the highestReceived value, if the offset is higher.
// UpdateHighestReceived updates the highestReceived value if the offset is higher .
func (c *streamFlowController) UpdateHighestReceived(offset protocol.ByteCount, final bool) error {
	c.mutex.Lock()
	defer c.mutex.Unlock()
	if c.receivedFinalOffset {
		if final && offset != c.highestReceived {
			return qerr.NewError(qerr.FinalSizeError, fmt.Sprintf("Received inconsistent final offset for stream %d (old: %d, new: %d bytes)", c.streamID, c.highestReceived, offset))
		}
		if offset > c.highestReceived {
			return qerr.NewError(qerr.FinalSizeError, fmt.Sprintf("Received offset %d for stream %d. Final offset was already received at %d", offset, c.streamID, c.highestReceived))
		}
	}
	if final {
		c.receivedFinalOffset = true
	}
	if offset == c.highestReceived {
		return nil
	}
	if offset <= c.highestReceived {
		if final {
			return qerr.NewError(qerr.FinalSizeError, fmt.Sprintf("Received final offset %d for stream %d, but already received offset %d before", offset, c.streamID, c.highestReceived))
		}
		return nil
	}
	increment := offset - c.highestReceived
	c.highestReceived = offset
	if c.checkFlowControlViolation() {
		return qerr.NewError(qerr.FlowControlError, fmt.Sprintf("Received %d bytes on stream %d, allowed %d bytes", offset, c.streamID, c.receiveWindow))
	}
	return c.connection.IncrementHighestReceived(increment)
}
func ( c * streamFlowController ) UpdateHighestReceived ( offset protocol . ByteCount , final bool ) error { c . mutex . Lock ( ) defer c . mutex . Unlock ( ) if c . receivedFinalOffset { if final && offset != c . highestReceived { return qerr . NewError ( qerr . FinalSizeError , fmt . Sprintf ( " " , c . streamID , c . highestReceived , offset ) ) } if offset > c . highestReceived { return qerr . NewError ( qerr . FinalSizeError , fmt . Sprintf ( " " , offset , c . streamID , c . highestReceived ) ) } } if final { c . receivedFinalOffset = true } if offset == c . highestReceived { return nil } if offset <= c . highestReceived { if final { return qerr . NewError ( qerr . FinalSizeError , fmt . Sprintf ( " " , offset , c . streamID , c . highestReceived ) ) } return nil } increment := offset - c . highestReceived c . highestReceived = offset if c . checkFlowControlViolation ( ) { return qerr . NewError ( qerr . FlowControlError , fmt . Sprintf ( " " , offset , c . streamID , c . receiveWindow ) ) } return c . connection . IncrementHighestReceived ( increment ) }
UpdateHighestReceived updates the highestReceived value, if the offset is higher.
UpdateHighestReceived updates the highestReceived value if the offset is higher .
// If the final offset for this stream is already known, check for consistency. // If we receive another final offset, check that it's the same. // Check that the offset is below the final offset. // A higher offset was received before. // This can happen due to reordering.