From 5e890a8f615f8ae16e3667a9b002117ac0168891 Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Thu, 23 Jun 2016 11:11:52 +0700 Subject: [PATCH] remove EntropyAccumulator from QUIC 34 AckHandler ref #55 --- ackhandlernew/entropy_accumulator.go | 23 ------------- ackhandlernew/entropy_accumulator_test.go | 41 ----------------------- 2 files changed, 64 deletions(-) delete mode 100644 ackhandlernew/entropy_accumulator.go delete mode 100644 ackhandlernew/entropy_accumulator_test.go diff --git a/ackhandlernew/entropy_accumulator.go b/ackhandlernew/entropy_accumulator.go deleted file mode 100644 index f5d1f9021..000000000 --- a/ackhandlernew/entropy_accumulator.go +++ /dev/null @@ -1,23 +0,0 @@ -package ackhandlernew - -import "github.com/lucas-clemente/quic-go/protocol" - -// EntropyAccumulator accumulates the entropy according to the QUIC docs -type EntropyAccumulator byte - -// Add the contribution of the entropy flag of a given packet number -func (e *EntropyAccumulator) Add(packetNumber protocol.PacketNumber, entropyFlag bool) { - if entropyFlag { - (*e) ^= 0x01 << (packetNumber % 8) - } -} - -// Subtract the contribution of the entropy flag of a given packet number -func (e *EntropyAccumulator) Subtract(packetNumber protocol.PacketNumber, entropyFlag bool) { - e.Add(packetNumber, entropyFlag) -} - -// Get the byte of entropy -func (e *EntropyAccumulator) Get() byte { - return byte(*e) -} diff --git a/ackhandlernew/entropy_accumulator_test.go b/ackhandlernew/entropy_accumulator_test.go deleted file mode 100644 index be101ad50..000000000 --- a/ackhandlernew/entropy_accumulator_test.go +++ /dev/null @@ -1,41 +0,0 @@ -package ackhandlernew - -import ( - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -var _ = Describe("EntropyAccumulator", func() { - It("initializes as zero", func() { - var e EntropyAccumulator - Expect(e.Get()).To(BeZero()) - }) - - Context("Add", func() { - It("adds entropy", func() { - var e EntropyAccumulator - e.Add(9, true) - Expect(e.Get()).To(Equal(byte(0x02))) - }) - - It("doesn't add entropy for zero entropy flags", func() { - var e EntropyAccumulator - e.Add(9, false) - Expect(e.Get()).To(BeZero()) - }) - }) - - Context("Subtract", func() { - It("calculates the correct entropy", func() { - var e1 EntropyAccumulator - e1.Add(3, true) - - var e2 EntropyAccumulator - e2.Add(1, true) - e2.Add(3, true) - e2.Subtract(1, true) - - Expect(e1).To(Equal(e2)) - }) - }) -})