copy AckHandler package

This commit is contained in:
Marten Seemann
2016-06-22 11:00:26 +07:00
parent e6ecb1f40c
commit 9dee97d2f9
12 changed files with 2008 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
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)
}