From fa07078d81496ec8b1b869c706b226251a9eeaf2 Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Thu, 2 Jul 2020 16:27:05 +0700 Subject: [PATCH] rename DataBlockedFrame.DataLimit to MaximumData --- framer_test.go | 2 +- fuzzing/frames/main.go | 4 ++-- internal/wire/data_blocked_frame.go | 8 ++++---- internal/wire/data_blocked_frame_test.go | 6 +++--- internal/wire/frame_parser_test.go | 2 +- internal/wire/log.go | 2 +- internal/wire/log_test.go | 4 ++-- qlog/frame.go | 2 +- qlog/frame_test.go | 2 +- session.go | 2 +- session_test.go | 2 +- 11 files changed, 18 insertions(+), 18 deletions(-) diff --git a/framer_test.go b/framer_test.go index 817f2b5e..28590275 100644 --- a/framer_test.go +++ b/framer_test.go @@ -73,7 +73,7 @@ var _ = Describe("Framer", func() { It("adds the right number of frames", func() { maxSize := protocol.ByteCount(1000) - bf := &wire.DataBlockedFrame{DataLimit: 0x1337} + bf := &wire.DataBlockedFrame{MaximumData: 0x1337} bfLen := bf.Length(version) numFrames := int(maxSize / bfLen) // max number of frames that fit into maxSize for i := 0; i < numFrames+1; i++ { diff --git a/fuzzing/frames/main.go b/fuzzing/frames/main.go index 1432e4ee..294a3326 100644 --- a/fuzzing/frames/main.go +++ b/fuzzing/frames/main.go @@ -165,10 +165,10 @@ func getFrames() []wire.Frame { MaxStreamNum: protocol.StreamNum(getRandomNumber()), }, &wire.DataBlockedFrame{ - DataLimit: protocol.ByteCount(getRandomNumber()), + MaximumData: protocol.ByteCount(getRandomNumber()), }, &wire.DataBlockedFrame{ - DataLimit: protocol.MaxByteCount, + MaximumData: protocol.MaxByteCount, }, &wire.StreamDataBlockedFrame{ StreamID: protocol.StreamID(getRandomNumber()), diff --git a/internal/wire/data_blocked_frame.go b/internal/wire/data_blocked_frame.go index 91c05ccf..57b06d80 100644 --- a/internal/wire/data_blocked_frame.go +++ b/internal/wire/data_blocked_frame.go @@ -9,7 +9,7 @@ import ( // A DataBlockedFrame is a DATA_BLOCKED frame type DataBlockedFrame struct { - DataLimit protocol.ByteCount + MaximumData protocol.ByteCount } func parseDataBlockedFrame(r *bytes.Reader, _ protocol.VersionNumber) (*DataBlockedFrame, error) { @@ -21,18 +21,18 @@ func parseDataBlockedFrame(r *bytes.Reader, _ protocol.VersionNumber) (*DataBloc return nil, err } return &DataBlockedFrame{ - DataLimit: protocol.ByteCount(offset), + MaximumData: protocol.ByteCount(offset), }, nil } func (f *DataBlockedFrame) Write(b *bytes.Buffer, version protocol.VersionNumber) error { typeByte := uint8(0x14) b.WriteByte(typeByte) - utils.WriteVarInt(b, uint64(f.DataLimit)) + utils.WriteVarInt(b, uint64(f.MaximumData)) return nil } // Length of a written frame func (f *DataBlockedFrame) Length(version protocol.VersionNumber) protocol.ByteCount { - return 1 + utils.VarIntLen(uint64(f.DataLimit)) + return 1 + utils.VarIntLen(uint64(f.MaximumData)) } diff --git a/internal/wire/data_blocked_frame_test.go b/internal/wire/data_blocked_frame_test.go index ac3588a1..7cff7552 100644 --- a/internal/wire/data_blocked_frame_test.go +++ b/internal/wire/data_blocked_frame_test.go @@ -19,7 +19,7 @@ var _ = Describe("DATA_BLOCKED frame", func() { b := bytes.NewReader(data) frame, err := parseDataBlockedFrame(b, versionIETFFrames) Expect(err).ToNot(HaveOccurred()) - Expect(frame.DataLimit).To(Equal(protocol.ByteCount(0x12345678))) + Expect(frame.MaximumData).To(Equal(protocol.ByteCount(0x12345678))) Expect(b.Len()).To(BeZero()) }) @@ -38,7 +38,7 @@ var _ = Describe("DATA_BLOCKED frame", func() { Context("when writing", func() { It("writes a sample frame", func() { b := &bytes.Buffer{} - frame := DataBlockedFrame{DataLimit: 0xdeadbeef} + frame := DataBlockedFrame{MaximumData: 0xdeadbeef} err := frame.Write(b, protocol.VersionWhatever) Expect(err).ToNot(HaveOccurred()) expected := []byte{0x14} @@ -47,7 +47,7 @@ var _ = Describe("DATA_BLOCKED frame", func() { }) It("has the correct min length", func() { - frame := DataBlockedFrame{DataLimit: 0x12345} + frame := DataBlockedFrame{MaximumData: 0x12345} Expect(frame.Length(versionIETFFrames)).To(Equal(1 + utils.VarIntLen(0x12345))) }) }) diff --git a/internal/wire/frame_parser_test.go b/internal/wire/frame_parser_test.go index 37d68547..509a1c2c 100644 --- a/internal/wire/frame_parser_test.go +++ b/internal/wire/frame_parser_test.go @@ -180,7 +180,7 @@ var _ = Describe("Frame parsing", func() { }) It("unpacks DATA_BLOCKED frames", func() { - f := &DataBlockedFrame{DataLimit: 0x1234} + f := &DataBlockedFrame{MaximumData: 0x1234} buf := &bytes.Buffer{} err := f.Write(buf, versionIETFFrames) Expect(err).ToNot(HaveOccurred()) diff --git a/internal/wire/log.go b/internal/wire/log.go index e72aa566..0a5cad78 100644 --- a/internal/wire/log.go +++ b/internal/wire/log.go @@ -40,7 +40,7 @@ func LogFrame(logger utils.Logger, frame Frame, sent bool) { case *MaxStreamDataFrame: logger.Debugf("\t%s &wire.MaxStreamDataFrame{StreamID: %d, MaximumStreamData: %d}", dir, f.StreamID, f.MaximumStreamData) case *DataBlockedFrame: - logger.Debugf("\t%s &wire.DataBlockedFrame{DataLimit: %d}", dir, f.DataLimit) + logger.Debugf("\t%s &wire.DataBlockedFrame{MaximumData: %d}", dir, f.MaximumData) case *StreamDataBlockedFrame: logger.Debugf("\t%s &wire.StreamDataBlockedFrame{StreamID: %d, DataLimit: %d}", dir, f.StreamID, f.DataLimit) case *MaxStreamsFrame: diff --git a/internal/wire/log_test.go b/internal/wire/log_test.go index 0d2a7ebf..9e8736f0 100644 --- a/internal/wire/log_test.go +++ b/internal/wire/log_test.go @@ -115,10 +115,10 @@ var _ = Describe("Frame logging", func() { It("logs DATA_BLOCKED frames", func() { frame := &DataBlockedFrame{ - DataLimit: 1000, + MaximumData: 1000, } LogFrame(logger, frame, false) - Expect(buf.String()).To(ContainSubstring("\t<- &wire.DataBlockedFrame{DataLimit: 1000}\n")) + Expect(buf.String()).To(ContainSubstring("\t<- &wire.DataBlockedFrame{MaximumData: 1000}\n")) }) It("logs STREAM_DATA_BLOCKED frames", func() { diff --git a/qlog/frame.go b/qlog/frame.go index daee30c9..9dce97ab 100644 --- a/qlog/frame.go +++ b/qlog/frame.go @@ -190,7 +190,7 @@ func marshalMaxStreamsFrame(enc *gojay.Encoder, f *wire.MaxStreamsFrame) { func marshalDataBlockedFrame(enc *gojay.Encoder, f *wire.DataBlockedFrame) { enc.StringKey("frame_type", "data_blocked") - enc.Int64Key("limit", int64(f.DataLimit)) + enc.Int64Key("limit", int64(f.MaximumData)) } func marshalStreamDataBlockedFrame(enc *gojay.Encoder, f *wire.StreamDataBlockedFrame) { diff --git a/qlog/frame_test.go b/qlog/frame_test.go index c5c1787f..4ee714a7 100644 --- a/qlog/frame_test.go +++ b/qlog/frame_test.go @@ -215,7 +215,7 @@ var _ = Describe("Frames", func() { It("marshals DATA_BLOCKED frames", func() { check( &wire.DataBlockedFrame{ - DataLimit: 1337, + MaximumData: 1337, }, map[string]interface{}{ "frame_type": "data_blocked", diff --git a/session.go b/session.go index 9162c0f9..8d527066 100644 --- a/session.go +++ b/session.go @@ -1504,7 +1504,7 @@ func (s *session) sendProbePacket(encLevel protocol.EncryptionLevel) error { func (s *session) sendPacket() (bool, error) { if isBlocked, offset := s.connFlowController.IsNewlyBlocked(); isBlocked { - s.framer.QueueControlFrame(&wire.DataBlockedFrame{DataLimit: offset}) + s.framer.QueueControlFrame(&wire.DataBlockedFrame{MaximumData: offset}) } s.windowUpdateQueue.QueueAll() diff --git a/session_test.go b/session_test.go index 90b5df65..519af3cf 100644 --- a/session_test.go +++ b/session_test.go @@ -1124,7 +1124,7 @@ var _ = Describe("Session", func() { sess.scheduleSending() Eventually(sent).Should(BeClosed()) frames, _ := sess.framer.AppendControlFrames(nil, 1000) - Expect(frames).To(Equal([]ackhandler.Frame{{Frame: &wire.DataBlockedFrame{DataLimit: 1337}}})) + Expect(frames).To(Equal([]ackhandler.Frame{{Frame: &wire.DataBlockedFrame{MaximumData: 1337}}})) }) It("doesn't send when the SentPacketHandler doesn't allow it", func() {