simplify stream ID handling in the incoming streams map (#5207)

* simplify stream ID handling in the incoming streams map

No functional change expected.

* protocol: move stream ID constant definition
This commit is contained in:
Marten Seemann
2025-06-08 18:25:36 +08:00
committed by GitHub
parent 3a53b81692
commit 576aa1747f
6 changed files with 214 additions and 138 deletions

View File

@@ -1,5 +1,7 @@
package protocol
import "github.com/quic-go/quic-go/quicvarint"
// StreamType encodes if this is a unidirectional or bidirectional stream
type StreamType uint8
@@ -23,6 +25,30 @@ const (
// MaxStreamCount is the maximum stream count value that can be sent in MAX_STREAMS frames
// and as the stream count in the transport parameters
MaxStreamCount StreamNum = 1 << 60
// MaxStreamID is the maximum stream ID
MaxStreamID StreamID = quicvarint.Max
)
const (
// FirstOutgoingBidiStreamClient is the first bidirectional stream opened by the client
FirstOutgoingBidiStreamClient StreamID = 0
// FirstOutgoingUniStreamClient is the first unidirectional stream opened by the client
FirstOutgoingUniStreamClient StreamID = 2
// FirstOutgoingBidiStreamServer is the first bidirectional stream opened by the server
FirstOutgoingBidiStreamServer StreamID = 1
// FirstOutgoingUniStreamServer is the first unidirectional stream opened by the server
FirstOutgoingUniStreamServer StreamID = 3
)
const (
// FirstIncomingBidiStreamServer is the first bidirectional stream accepted by the server
FirstIncomingBidiStreamServer = FirstOutgoingBidiStreamClient
// FirstIncomingUniStreamServer is the first unidirectional stream accepted by the server
FirstIncomingUniStreamServer = FirstOutgoingUniStreamClient
// FirstIncomingBidiStreamClient is the first bidirectional stream accepted by the client
FirstIncomingBidiStreamClient = FirstOutgoingBidiStreamServer
// FirstIncomingUniStreamClient is the first unidirectional stream accepted by the client
FirstIncomingUniStreamClient = FirstOutgoingUniStreamServer
)
// StreamID calculates the stream ID.