rename typeFEC->typeParity

This commit is contained in:
xtaci
2019-04-23 11:59:03 +08:00
parent 348f7245b9
commit 31ca7b731d
3 changed files with 5 additions and 5 deletions
+2 -2
View File
@@ -11,7 +11,7 @@ const (
fecHeaderSize = 6
fecHeaderSizePlus2 = fecHeaderSize + 2 // plus 2B data size
typeData = 0xf1
typeFEC = 0xf2
typeParity = 0xf2
)
// fecPacket is a decoded FEC packet
@@ -298,7 +298,7 @@ func (enc *fecEncoder) markData(data []byte) {
func (enc *fecEncoder) markParity(data []byte) {
binary.LittleEndian.PutUint32(data, enc.next)
binary.LittleEndian.PutUint16(data[4:], typeFEC)
binary.LittleEndian.PutUint16(data[4:], typeParity)
// sequence wrap will only happen at parity shard
enc.next = (enc.next + 1) % enc.paws
}
+1 -1
View File
@@ -20,7 +20,7 @@ func BenchmarkFECDecode(b *testing.B) {
pkt := make([]byte, payLoad)
binary.LittleEndian.PutUint32(pkt, uint32(i))
if i%(dataSize+paritySize) >= dataSize {
binary.LittleEndian.PutUint16(pkt[4:], typeFEC)
binary.LittleEndian.PutUint16(pkt[4:], typeParity)
} else {
binary.LittleEndian.PutUint16(pkt[4:], typeData)
}
+2 -2
View File
@@ -554,8 +554,8 @@ func (s *UDPSession) kcpInput(data []byte) {
if s.fecDecoder != nil {
if len(data) > fecHeaderSize { // must be larger than fec header size
f := fecPacket(data)
if f.flag() == typeData || f.flag() == typeFEC { // header check
if f.flag() == typeFEC {
if f.flag() == typeData || f.flag() == typeParity { // header check
if f.flag() == typeParity {
fecParityShards++
}
recovers := s.fecDecoder.decode(f)