slidge-whatsapp 0.3.1__cp312-cp312-manylinux_2_36_aarch64.whl → 0.3.4__cp312-cp312-manylinux_2_36_aarch64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of slidge-whatsapp might be problematic. Click here for more details.

Files changed (74) hide show
  1. slidge_whatsapp/generated/_whatsapp.cpython-312-aarch64-linux-gnu.h +172 -172
  2. slidge_whatsapp/generated/_whatsapp.cpython-312-aarch64-linux-gnu.so +0 -0
  3. slidge_whatsapp/generated/build.py +138 -138
  4. slidge_whatsapp/generated/go.py +1 -1
  5. slidge_whatsapp/generated/whatsapp.c +1479 -1479
  6. slidge_whatsapp/generated/whatsapp.go +987 -987
  7. slidge_whatsapp/generated/whatsapp.py +1187 -1187
  8. slidge_whatsapp/generated/whatsapp_go.h +172 -172
  9. slidge_whatsapp/go.mod +9 -9
  10. slidge_whatsapp/go.sum +18 -18
  11. slidge_whatsapp/vendor/go.mau.fi/libsignal/session/SessionCipher.go +7 -2
  12. slidge_whatsapp/vendor/go.mau.fi/util/dbutil/module.go +2 -1
  13. slidge_whatsapp/vendor/go.mau.fi/util/dbutil/upgradetable.go +3 -0
  14. slidge_whatsapp/vendor/go.mau.fi/util/exsync/syncmap.go +48 -7
  15. slidge_whatsapp/vendor/go.mau.fi/util/exsync/syncset.go +13 -0
  16. slidge_whatsapp/vendor/go.mau.fi/util/jsontime/helpers.go +16 -5
  17. slidge_whatsapp/vendor/go.mau.fi/util/jsontime/integer.go +27 -12
  18. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/appstate/encode.go +39 -28
  19. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/appstate.go +17 -2
  20. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/armadillomessage.go +2 -1
  21. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/internals.go +18 -6
  22. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/message.go +40 -16
  23. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/pair.go +24 -21
  24. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/prekeys.go +21 -0
  25. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waE2E/WAWebProtobufsE2E.pb.go +3213 -2851
  26. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waE2E/WAWebProtobufsE2E.proto +108 -74
  27. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waStatusAttributions/WAStatusAttributions.pb.go +7 -3
  28. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waStatusAttributions/WAStatusAttributions.proto +1 -0
  29. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waSyncAction/WASyncAction.pb.go +7 -3
  30. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waSyncAction/WASyncAction.proto +1 -0
  31. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waWeb/WAWebProtobufsWeb.pb.go +35 -23
  32. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waWeb/WAWebProtobufsWeb.proto +5 -3
  33. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/receipt.go +47 -16
  34. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/retry.go +4 -10
  35. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/send.go +28 -42
  36. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/sendfb.go +33 -32
  37. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/store/clientpayload.go +1 -1
  38. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/store/noop.go +5 -1
  39. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/store/sessioncache.go +125 -0
  40. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/store/signal.go +8 -0
  41. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/store/sqlstore/store.go +34 -11
  42. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/store/store.go +5 -3
  43. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/types/jid.go +24 -9
  44. slidge_whatsapp/vendor/go.mau.fi/whatsmeow/user.go +12 -1
  45. slidge_whatsapp/vendor/golang.org/x/crypto/curve25519/curve25519.go +7 -4
  46. slidge_whatsapp/vendor/golang.org/x/net/http2/config.go +11 -6
  47. slidge_whatsapp/vendor/golang.org/x/net/http2/config_go125.go +15 -0
  48. slidge_whatsapp/vendor/golang.org/x/net/http2/config_go126.go +15 -0
  49. slidge_whatsapp/vendor/golang.org/x/net/http2/frame.go +24 -1
  50. slidge_whatsapp/vendor/golang.org/x/net/http2/http2.go +0 -1
  51. slidge_whatsapp/vendor/golang.org/x/net/http2/server.go +35 -26
  52. slidge_whatsapp/vendor/golang.org/x/net/http2/transport.go +4 -2
  53. slidge_whatsapp/vendor/golang.org/x/net/http2/writesched.go +2 -0
  54. slidge_whatsapp/vendor/golang.org/x/net/http2/{writesched_priority.go → writesched_priority_rfc7540.go} +52 -52
  55. slidge_whatsapp/vendor/golang.org/x/net/http2/writesched_priority_rfc9128.go +209 -0
  56. slidge_whatsapp/vendor/golang.org/x/net/http2/writesched_roundrobin.go +1 -1
  57. slidge_whatsapp/vendor/golang.org/x/net/internal/httpcommon/request.go +2 -2
  58. slidge_whatsapp/vendor/golang.org/x/net/internal/socks/socks.go +1 -1
  59. slidge_whatsapp/vendor/golang.org/x/sys/unix/affinity_linux.go +9 -0
  60. slidge_whatsapp/vendor/golang.org/x/sys/unix/fdset.go +1 -3
  61. slidge_whatsapp/vendor/golang.org/x/sys/unix/ifreq_linux.go +1 -3
  62. slidge_whatsapp/vendor/golang.org/x/sys/unix/mkall.sh +1 -0
  63. slidge_whatsapp/vendor/golang.org/x/sys/unix/syscall_linux.go +1 -3
  64. slidge_whatsapp/vendor/golang.org/x/sys/unix/syscall_netbsd.go +17 -0
  65. slidge_whatsapp/vendor/golang.org/x/sys/windows/syscall_windows.go +2 -0
  66. slidge_whatsapp/vendor/golang.org/x/sys/windows/types_windows.go +16 -0
  67. slidge_whatsapp/vendor/golang.org/x/sys/windows/zsyscall_windows.go +18 -0
  68. slidge_whatsapp/vendor/golang.org/x/text/unicode/bidi/core.go +2 -9
  69. slidge_whatsapp/vendor/modules.txt +10 -10
  70. {slidge_whatsapp-0.3.1.dist-info → slidge_whatsapp-0.3.4.dist-info}/METADATA +1 -1
  71. {slidge_whatsapp-0.3.1.dist-info → slidge_whatsapp-0.3.4.dist-info}/RECORD +74 -70
  72. {slidge_whatsapp-0.3.1.dist-info → slidge_whatsapp-0.3.4.dist-info}/WHEEL +0 -0
  73. {slidge_whatsapp-0.3.1.dist-info → slidge_whatsapp-0.3.4.dist-info}/entry_points.txt +0 -0
  74. {slidge_whatsapp-0.3.1.dist-info → slidge_whatsapp-0.3.4.dist-info}/licenses/LICENSE +0 -0
@@ -347,7 +347,7 @@ func (fr *Framer) maxHeaderListSize() uint32 {
347
347
  func (f *Framer) startWrite(ftype FrameType, flags Flags, streamID uint32) {
348
348
  // Write the FrameHeader.
349
349
  f.wbuf = append(f.wbuf[:0],
350
- 0, // 3 bytes of length, filled in in endWrite
350
+ 0, // 3 bytes of length, filled in endWrite
351
351
  0,
352
352
  0,
353
353
  byte(ftype),
@@ -1152,6 +1152,15 @@ type PriorityFrame struct {
1152
1152
  PriorityParam
1153
1153
  }
1154
1154
 
1155
+ var defaultRFC9218Priority = PriorityParam{
1156
+ incremental: 0,
1157
+ urgency: 3,
1158
+ }
1159
+
1160
+ // Note that HTTP/2 has had two different prioritization schemes, and
1161
+ // PriorityParam struct below is a superset of both schemes. The exported
1162
+ // symbols are from RFC 7540 and the non-exported ones are from RFC 9218.
1163
+
1155
1164
  // PriorityParam are the stream prioritzation parameters.
1156
1165
  type PriorityParam struct {
1157
1166
  // StreamDep is a 31-bit stream identifier for the
@@ -1167,6 +1176,20 @@ type PriorityParam struct {
1167
1176
  // the spec, "Add one to the value to obtain a weight between
1168
1177
  // 1 and 256."
1169
1178
  Weight uint8
1179
+
1180
+ // "The urgency (u) parameter value is Integer (see Section 3.3.1 of
1181
+ // [STRUCTURED-FIELDS]), between 0 and 7 inclusive, in descending order of
1182
+ // priority. The default is 3."
1183
+ urgency uint8
1184
+
1185
+ // "The incremental (i) parameter value is Boolean (see Section 3.3.6 of
1186
+ // [STRUCTURED-FIELDS]). It indicates if an HTTP response can be processed
1187
+ // incrementally, i.e., provide some meaningful output as chunks of the
1188
+ // response arrive."
1189
+ //
1190
+ // We use uint8 (i.e. 0 is false, 1 is true) instead of bool so we can
1191
+ // avoid unnecessary type conversions and because either type takes 1 byte.
1192
+ incremental uint8
1170
1193
  }
1171
1194
 
1172
1195
  func (p PriorityParam) IsZero() bool {
@@ -34,7 +34,6 @@ var (
34
34
  VerboseLogs bool
35
35
  logFrameWrites bool
36
36
  logFrameReads bool
37
- inTests bool
38
37
 
39
38
  // Enabling extended CONNECT by causes browsers to attempt to use
40
39
  // WebSockets-over-HTTP/2. This results in problems when the server's websocket
@@ -181,6 +181,10 @@ type Server struct {
181
181
  type serverInternalState struct {
182
182
  mu sync.Mutex
183
183
  activeConns map[*serverConn]struct{}
184
+
185
+ // Pool of error channels. This is per-Server rather than global
186
+ // because channels can't be reused across synctest bubbles.
187
+ errChanPool sync.Pool
184
188
  }
185
189
 
186
190
  func (s *serverInternalState) registerConn(sc *serverConn) {
@@ -212,6 +216,27 @@ func (s *serverInternalState) startGracefulShutdown() {
212
216
  s.mu.Unlock()
213
217
  }
214
218
 
219
+ // Global error channel pool used for uninitialized Servers.
220
+ // We use a per-Server pool when possible to avoid using channels across synctest bubbles.
221
+ var errChanPool = sync.Pool{
222
+ New: func() any { return make(chan error, 1) },
223
+ }
224
+
225
+ func (s *serverInternalState) getErrChan() chan error {
226
+ if s == nil {
227
+ return errChanPool.Get().(chan error) // Server used without calling ConfigureServer
228
+ }
229
+ return s.errChanPool.Get().(chan error)
230
+ }
231
+
232
+ func (s *serverInternalState) putErrChan(ch chan error) {
233
+ if s == nil {
234
+ errChanPool.Put(ch) // Server used without calling ConfigureServer
235
+ return
236
+ }
237
+ s.errChanPool.Put(ch)
238
+ }
239
+
215
240
  // ConfigureServer adds HTTP/2 support to a net/http Server.
216
241
  //
217
242
  // The configuration conf may be nil.
@@ -224,7 +249,10 @@ func ConfigureServer(s *http.Server, conf *Server) error {
224
249
  if conf == nil {
225
250
  conf = new(Server)
226
251
  }
227
- conf.state = &serverInternalState{activeConns: make(map[*serverConn]struct{})}
252
+ conf.state = &serverInternalState{
253
+ activeConns: make(map[*serverConn]struct{}),
254
+ errChanPool: sync.Pool{New: func() any { return make(chan error, 1) }},
255
+ }
228
256
  if h1, h2 := s, conf; h2.IdleTimeout == 0 {
229
257
  if h1.IdleTimeout != 0 {
230
258
  h2.IdleTimeout = h1.IdleTimeout
@@ -1124,25 +1152,6 @@ func (sc *serverConn) readPreface() error {
1124
1152
  }
1125
1153
  }
1126
1154
 
1127
- var errChanPool = sync.Pool{
1128
- New: func() interface{} { return make(chan error, 1) },
1129
- }
1130
-
1131
- func getErrChan() chan error {
1132
- if inTests {
1133
- // Channels cannot be reused across synctest tests.
1134
- return make(chan error, 1)
1135
- } else {
1136
- return errChanPool.Get().(chan error)
1137
- }
1138
- }
1139
-
1140
- func putErrChan(ch chan error) {
1141
- if !inTests {
1142
- errChanPool.Put(ch)
1143
- }
1144
- }
1145
-
1146
1155
  var writeDataPool = sync.Pool{
1147
1156
  New: func() interface{} { return new(writeData) },
1148
1157
  }
@@ -1150,7 +1159,7 @@ var writeDataPool = sync.Pool{
1150
1159
  // writeDataFromHandler writes DATA response frames from a handler on
1151
1160
  // the given stream.
1152
1161
  func (sc *serverConn) writeDataFromHandler(stream *stream, data []byte, endStream bool) error {
1153
- ch := getErrChan()
1162
+ ch := sc.srv.state.getErrChan()
1154
1163
  writeArg := writeDataPool.Get().(*writeData)
1155
1164
  *writeArg = writeData{stream.id, data, endStream}
1156
1165
  err := sc.writeFrameFromHandler(FrameWriteRequest{
@@ -1182,7 +1191,7 @@ func (sc *serverConn) writeDataFromHandler(stream *stream, data []byte, endStrea
1182
1191
  return errStreamClosed
1183
1192
  }
1184
1193
  }
1185
- putErrChan(ch)
1194
+ sc.srv.state.putErrChan(ch)
1186
1195
  if frameWriteDone {
1187
1196
  writeDataPool.Put(writeArg)
1188
1197
  }
@@ -2436,7 +2445,7 @@ func (sc *serverConn) writeHeaders(st *stream, headerData *writeResHeaders) erro
2436
2445
  // waiting for this frame to be written, so an http.Flush mid-handler
2437
2446
  // writes out the correct value of keys, before a handler later potentially
2438
2447
  // mutates it.
2439
- errc = getErrChan()
2448
+ errc = sc.srv.state.getErrChan()
2440
2449
  }
2441
2450
  if err := sc.writeFrameFromHandler(FrameWriteRequest{
2442
2451
  write: headerData,
@@ -2448,7 +2457,7 @@ func (sc *serverConn) writeHeaders(st *stream, headerData *writeResHeaders) erro
2448
2457
  if errc != nil {
2449
2458
  select {
2450
2459
  case err := <-errc:
2451
- putErrChan(errc)
2460
+ sc.srv.state.putErrChan(errc)
2452
2461
  return err
2453
2462
  case <-sc.doneServing:
2454
2463
  return errClientDisconnected
@@ -3129,7 +3138,7 @@ func (w *responseWriter) Push(target string, opts *http.PushOptions) error {
3129
3138
  method: opts.Method,
3130
3139
  url: u,
3131
3140
  header: cloneHeader(opts.Header),
3132
- done: getErrChan(),
3141
+ done: sc.srv.state.getErrChan(),
3133
3142
  }
3134
3143
 
3135
3144
  select {
@@ -3146,7 +3155,7 @@ func (w *responseWriter) Push(target string, opts *http.PushOptions) error {
3146
3155
  case <-st.cw:
3147
3156
  return errStreamClosed
3148
3157
  case err := <-msg.done:
3149
- putErrChan(msg.done)
3158
+ sc.srv.state.putErrChan(msg.done)
3150
3159
  return err
3151
3160
  }
3152
3161
  }
@@ -355,6 +355,7 @@ type ClientConn struct {
355
355
  readIdleTimeout time.Duration
356
356
  pingTimeout time.Duration
357
357
  extendedConnectAllowed bool
358
+ strictMaxConcurrentStreams bool
358
359
 
359
360
  // rstStreamPingsBlocked works around an unfortunate gRPC behavior.
360
361
  // gRPC strictly limits the number of PING frames that it will receive.
@@ -784,7 +785,8 @@ func (t *Transport) newClientConn(c net.Conn, singleUse bool) (*ClientConn, erro
784
785
  initialWindowSize: 65535, // spec default
785
786
  initialStreamRecvWindowSize: conf.MaxUploadBufferPerStream,
786
787
  maxConcurrentStreams: initialMaxConcurrentStreams, // "infinite", per spec. Use a smaller value until we have received server settings.
787
- peerMaxHeaderListSize: 0xffffffffffffffff, // "infinite", per spec. Use 2^64-1 instead.
788
+ strictMaxConcurrentStreams: conf.StrictMaxConcurrentRequests,
789
+ peerMaxHeaderListSize: 0xffffffffffffffff, // "infinite", per spec. Use 2^64-1 instead.
788
790
  streams: make(map[uint32]*clientStream),
789
791
  singleUse: singleUse,
790
792
  seenSettingsChan: make(chan struct{}),
@@ -1018,7 +1020,7 @@ func (cc *ClientConn) idleStateLocked() (st clientConnIdleState) {
1018
1020
  return
1019
1021
  }
1020
1022
  var maxConcurrentOkay bool
1021
- if cc.t.StrictMaxConcurrentStreams {
1023
+ if cc.strictMaxConcurrentStreams {
1022
1024
  // We'll tell the caller we can take a new request to
1023
1025
  // prevent the caller from dialing a new TCP
1024
1026
  // connection, but then we'll block later before
@@ -42,6 +42,8 @@ type OpenStreamOptions struct {
42
42
  // PusherID is zero if the stream was initiated by the client. Otherwise,
43
43
  // PusherID names the stream that pushed the newly opened stream.
44
44
  PusherID uint32
45
+ // priority is used to set the priority of the newly opened stream.
46
+ priority PriorityParam
45
47
  }
46
48
 
47
49
  // FrameWriteRequest is a request to write a frame.
@@ -11,7 +11,7 @@ import (
11
11
  )
12
12
 
13
13
  // RFC 7540, Section 5.3.5: the default weight is 16.
14
- const priorityDefaultWeight = 15 // 16 = 15 + 1
14
+ const priorityDefaultWeightRFC7540 = 15 // 16 = 15 + 1
15
15
 
16
16
  // PriorityWriteSchedulerConfig configures a priorityWriteScheduler.
17
17
  type PriorityWriteSchedulerConfig struct {
@@ -66,8 +66,8 @@ func NewPriorityWriteScheduler(cfg *PriorityWriteSchedulerConfig) WriteScheduler
66
66
  }
67
67
  }
68
68
 
69
- ws := &priorityWriteScheduler{
70
- nodes: make(map[uint32]*priorityNode),
69
+ ws := &priorityWriteSchedulerRFC7540{
70
+ nodes: make(map[uint32]*priorityNodeRFC7540),
71
71
  maxClosedNodesInTree: cfg.MaxClosedNodesInTree,
72
72
  maxIdleNodesInTree: cfg.MaxIdleNodesInTree,
73
73
  enableWriteThrottle: cfg.ThrottleOutOfOrderWrites,
@@ -81,32 +81,32 @@ func NewPriorityWriteScheduler(cfg *PriorityWriteSchedulerConfig) WriteScheduler
81
81
  return ws
82
82
  }
83
83
 
84
- type priorityNodeState int
84
+ type priorityNodeStateRFC7540 int
85
85
 
86
86
  const (
87
- priorityNodeOpen priorityNodeState = iota
88
- priorityNodeClosed
89
- priorityNodeIdle
87
+ priorityNodeOpenRFC7540 priorityNodeStateRFC7540 = iota
88
+ priorityNodeClosedRFC7540
89
+ priorityNodeIdleRFC7540
90
90
  )
91
91
 
92
- // priorityNode is a node in an HTTP/2 priority tree.
92
+ // priorityNodeRFC7540 is a node in an HTTP/2 priority tree.
93
93
  // Each node is associated with a single stream ID.
94
94
  // See RFC 7540, Section 5.3.
95
- type priorityNode struct {
96
- q writeQueue // queue of pending frames to write
97
- id uint32 // id of the stream, or 0 for the root of the tree
98
- weight uint8 // the actual weight is weight+1, so the value is in [1,256]
99
- state priorityNodeState // open | closed | idle
100
- bytes int64 // number of bytes written by this node, or 0 if closed
101
- subtreeBytes int64 // sum(node.bytes) of all nodes in this subtree
95
+ type priorityNodeRFC7540 struct {
96
+ q writeQueue // queue of pending frames to write
97
+ id uint32 // id of the stream, or 0 for the root of the tree
98
+ weight uint8 // the actual weight is weight+1, so the value is in [1,256]
99
+ state priorityNodeStateRFC7540 // open | closed | idle
100
+ bytes int64 // number of bytes written by this node, or 0 if closed
101
+ subtreeBytes int64 // sum(node.bytes) of all nodes in this subtree
102
102
 
103
103
  // These links form the priority tree.
104
- parent *priorityNode
105
- kids *priorityNode // start of the kids list
106
- prev, next *priorityNode // doubly-linked list of siblings
104
+ parent *priorityNodeRFC7540
105
+ kids *priorityNodeRFC7540 // start of the kids list
106
+ prev, next *priorityNodeRFC7540 // doubly-linked list of siblings
107
107
  }
108
108
 
109
- func (n *priorityNode) setParent(parent *priorityNode) {
109
+ func (n *priorityNodeRFC7540) setParent(parent *priorityNodeRFC7540) {
110
110
  if n == parent {
111
111
  panic("setParent to self")
112
112
  }
@@ -141,7 +141,7 @@ func (n *priorityNode) setParent(parent *priorityNode) {
141
141
  }
142
142
  }
143
143
 
144
- func (n *priorityNode) addBytes(b int64) {
144
+ func (n *priorityNodeRFC7540) addBytes(b int64) {
145
145
  n.bytes += b
146
146
  for ; n != nil; n = n.parent {
147
147
  n.subtreeBytes += b
@@ -154,7 +154,7 @@ func (n *priorityNode) addBytes(b int64) {
154
154
  //
155
155
  // f(n, openParent) takes two arguments: the node to visit, n, and a bool that is true
156
156
  // if any ancestor p of n is still open (ignoring the root node).
157
- func (n *priorityNode) walkReadyInOrder(openParent bool, tmp *[]*priorityNode, f func(*priorityNode, bool) bool) bool {
157
+ func (n *priorityNodeRFC7540) walkReadyInOrder(openParent bool, tmp *[]*priorityNodeRFC7540, f func(*priorityNodeRFC7540, bool) bool) bool {
158
158
  if !n.q.empty() && f(n, openParent) {
159
159
  return true
160
160
  }
@@ -165,7 +165,7 @@ func (n *priorityNode) walkReadyInOrder(openParent bool, tmp *[]*priorityNode, f
165
165
  // Don't consider the root "open" when updating openParent since
166
166
  // we can't send data frames on the root stream (only control frames).
167
167
  if n.id != 0 {
168
- openParent = openParent || (n.state == priorityNodeOpen)
168
+ openParent = openParent || (n.state == priorityNodeOpenRFC7540)
169
169
  }
170
170
 
171
171
  // Common case: only one kid or all kids have the same weight.
@@ -195,7 +195,7 @@ func (n *priorityNode) walkReadyInOrder(openParent bool, tmp *[]*priorityNode, f
195
195
  *tmp = append(*tmp, n.kids)
196
196
  n.kids.setParent(nil)
197
197
  }
198
- sort.Sort(sortPriorityNodeSiblings(*tmp))
198
+ sort.Sort(sortPriorityNodeSiblingsRFC7540(*tmp))
199
199
  for i := len(*tmp) - 1; i >= 0; i-- {
200
200
  (*tmp)[i].setParent(n) // setParent inserts at the head of n.kids
201
201
  }
@@ -207,11 +207,11 @@ func (n *priorityNode) walkReadyInOrder(openParent bool, tmp *[]*priorityNode, f
207
207
  return false
208
208
  }
209
209
 
210
- type sortPriorityNodeSiblings []*priorityNode
210
+ type sortPriorityNodeSiblingsRFC7540 []*priorityNodeRFC7540
211
211
 
212
- func (z sortPriorityNodeSiblings) Len() int { return len(z) }
213
- func (z sortPriorityNodeSiblings) Swap(i, k int) { z[i], z[k] = z[k], z[i] }
214
- func (z sortPriorityNodeSiblings) Less(i, k int) bool {
212
+ func (z sortPriorityNodeSiblingsRFC7540) Len() int { return len(z) }
213
+ func (z sortPriorityNodeSiblingsRFC7540) Swap(i, k int) { z[i], z[k] = z[k], z[i] }
214
+ func (z sortPriorityNodeSiblingsRFC7540) Less(i, k int) bool {
215
215
  // Prefer the subtree that has sent fewer bytes relative to its weight.
216
216
  // See sections 5.3.2 and 5.3.4.
217
217
  wi, bi := float64(z[i].weight+1), float64(z[i].subtreeBytes)
@@ -225,13 +225,13 @@ func (z sortPriorityNodeSiblings) Less(i, k int) bool {
225
225
  return bi/bk <= wi/wk
226
226
  }
227
227
 
228
- type priorityWriteScheduler struct {
228
+ type priorityWriteSchedulerRFC7540 struct {
229
229
  // root is the root of the priority tree, where root.id = 0.
230
230
  // The root queues control frames that are not associated with any stream.
231
- root priorityNode
231
+ root priorityNodeRFC7540
232
232
 
233
233
  // nodes maps stream ids to priority tree nodes.
234
- nodes map[uint32]*priorityNode
234
+ nodes map[uint32]*priorityNodeRFC7540
235
235
 
236
236
  // maxID is the maximum stream id in nodes.
237
237
  maxID uint32
@@ -239,7 +239,7 @@ type priorityWriteScheduler struct {
239
239
  // lists of nodes that have been closed or are idle, but are kept in
240
240
  // the tree for improved prioritization. When the lengths exceed either
241
241
  // maxClosedNodesInTree or maxIdleNodesInTree, old nodes are discarded.
242
- closedNodes, idleNodes []*priorityNode
242
+ closedNodes, idleNodes []*priorityNodeRFC7540
243
243
 
244
244
  // From the config.
245
245
  maxClosedNodesInTree int
@@ -248,19 +248,19 @@ type priorityWriteScheduler struct {
248
248
  enableWriteThrottle bool
249
249
 
250
250
  // tmp is scratch space for priorityNode.walkReadyInOrder to reduce allocations.
251
- tmp []*priorityNode
251
+ tmp []*priorityNodeRFC7540
252
252
 
253
253
  // pool of empty queues for reuse.
254
254
  queuePool writeQueuePool
255
255
  }
256
256
 
257
- func (ws *priorityWriteScheduler) OpenStream(streamID uint32, options OpenStreamOptions) {
257
+ func (ws *priorityWriteSchedulerRFC7540) OpenStream(streamID uint32, options OpenStreamOptions) {
258
258
  // The stream may be currently idle but cannot be opened or closed.
259
259
  if curr := ws.nodes[streamID]; curr != nil {
260
- if curr.state != priorityNodeIdle {
260
+ if curr.state != priorityNodeIdleRFC7540 {
261
261
  panic(fmt.Sprintf("stream %d already opened", streamID))
262
262
  }
263
- curr.state = priorityNodeOpen
263
+ curr.state = priorityNodeOpenRFC7540
264
264
  return
265
265
  }
266
266
 
@@ -272,11 +272,11 @@ func (ws *priorityWriteScheduler) OpenStream(streamID uint32, options OpenStream
272
272
  if parent == nil {
273
273
  parent = &ws.root
274
274
  }
275
- n := &priorityNode{
275
+ n := &priorityNodeRFC7540{
276
276
  q: *ws.queuePool.get(),
277
277
  id: streamID,
278
- weight: priorityDefaultWeight,
279
- state: priorityNodeOpen,
278
+ weight: priorityDefaultWeightRFC7540,
279
+ state: priorityNodeOpenRFC7540,
280
280
  }
281
281
  n.setParent(parent)
282
282
  ws.nodes[streamID] = n
@@ -285,19 +285,19 @@ func (ws *priorityWriteScheduler) OpenStream(streamID uint32, options OpenStream
285
285
  }
286
286
  }
287
287
 
288
- func (ws *priorityWriteScheduler) CloseStream(streamID uint32) {
288
+ func (ws *priorityWriteSchedulerRFC7540) CloseStream(streamID uint32) {
289
289
  if streamID == 0 {
290
290
  panic("violation of WriteScheduler interface: cannot close stream 0")
291
291
  }
292
292
  if ws.nodes[streamID] == nil {
293
293
  panic(fmt.Sprintf("violation of WriteScheduler interface: unknown stream %d", streamID))
294
294
  }
295
- if ws.nodes[streamID].state != priorityNodeOpen {
295
+ if ws.nodes[streamID].state != priorityNodeOpenRFC7540 {
296
296
  panic(fmt.Sprintf("violation of WriteScheduler interface: stream %d already closed", streamID))
297
297
  }
298
298
 
299
299
  n := ws.nodes[streamID]
300
- n.state = priorityNodeClosed
300
+ n.state = priorityNodeClosedRFC7540
301
301
  n.addBytes(-n.bytes)
302
302
 
303
303
  q := n.q
@@ -310,7 +310,7 @@ func (ws *priorityWriteScheduler) CloseStream(streamID uint32) {
310
310
  }
311
311
  }
312
312
 
313
- func (ws *priorityWriteScheduler) AdjustStream(streamID uint32, priority PriorityParam) {
313
+ func (ws *priorityWriteSchedulerRFC7540) AdjustStream(streamID uint32, priority PriorityParam) {
314
314
  if streamID == 0 {
315
315
  panic("adjustPriority on root")
316
316
  }
@@ -324,11 +324,11 @@ func (ws *priorityWriteScheduler) AdjustStream(streamID uint32, priority Priorit
324
324
  return
325
325
  }
326
326
  ws.maxID = streamID
327
- n = &priorityNode{
327
+ n = &priorityNodeRFC7540{
328
328
  q: *ws.queuePool.get(),
329
329
  id: streamID,
330
- weight: priorityDefaultWeight,
331
- state: priorityNodeIdle,
330
+ weight: priorityDefaultWeightRFC7540,
331
+ state: priorityNodeIdleRFC7540,
332
332
  }
333
333
  n.setParent(&ws.root)
334
334
  ws.nodes[streamID] = n
@@ -340,7 +340,7 @@ func (ws *priorityWriteScheduler) AdjustStream(streamID uint32, priority Priorit
340
340
  parent := ws.nodes[priority.StreamDep]
341
341
  if parent == nil {
342
342
  n.setParent(&ws.root)
343
- n.weight = priorityDefaultWeight
343
+ n.weight = priorityDefaultWeightRFC7540
344
344
  return
345
345
  }
346
346
 
@@ -381,8 +381,8 @@ func (ws *priorityWriteScheduler) AdjustStream(streamID uint32, priority Priorit
381
381
  n.weight = priority.Weight
382
382
  }
383
383
 
384
- func (ws *priorityWriteScheduler) Push(wr FrameWriteRequest) {
385
- var n *priorityNode
384
+ func (ws *priorityWriteSchedulerRFC7540) Push(wr FrameWriteRequest) {
385
+ var n *priorityNodeRFC7540
386
386
  if wr.isControl() {
387
387
  n = &ws.root
388
388
  } else {
@@ -401,8 +401,8 @@ func (ws *priorityWriteScheduler) Push(wr FrameWriteRequest) {
401
401
  n.q.push(wr)
402
402
  }
403
403
 
404
- func (ws *priorityWriteScheduler) Pop() (wr FrameWriteRequest, ok bool) {
405
- ws.root.walkReadyInOrder(false, &ws.tmp, func(n *priorityNode, openParent bool) bool {
404
+ func (ws *priorityWriteSchedulerRFC7540) Pop() (wr FrameWriteRequest, ok bool) {
405
+ ws.root.walkReadyInOrder(false, &ws.tmp, func(n *priorityNodeRFC7540, openParent bool) bool {
406
406
  limit := int32(math.MaxInt32)
407
407
  if openParent {
408
408
  limit = ws.writeThrottleLimit
@@ -428,7 +428,7 @@ func (ws *priorityWriteScheduler) Pop() (wr FrameWriteRequest, ok bool) {
428
428
  return wr, ok
429
429
  }
430
430
 
431
- func (ws *priorityWriteScheduler) addClosedOrIdleNode(list *[]*priorityNode, maxSize int, n *priorityNode) {
431
+ func (ws *priorityWriteSchedulerRFC7540) addClosedOrIdleNode(list *[]*priorityNodeRFC7540, maxSize int, n *priorityNodeRFC7540) {
432
432
  if maxSize == 0 {
433
433
  return
434
434
  }
@@ -442,7 +442,7 @@ func (ws *priorityWriteScheduler) addClosedOrIdleNode(list *[]*priorityNode, max
442
442
  *list = append(*list, n)
443
443
  }
444
444
 
445
- func (ws *priorityWriteScheduler) removeNode(n *priorityNode) {
445
+ func (ws *priorityWriteSchedulerRFC7540) removeNode(n *priorityNodeRFC7540) {
446
446
  for n.kids != nil {
447
447
  n.kids.setParent(n.parent)
448
448
  }