Refactor HeaderTags

This commit is contained in:
Chih Cheng Liang
2019-08-02 17:14:43 +08:00
parent 29fbb9e40a
commit 36b7e8ded9
4 changed files with 31 additions and 27 deletions

View File

@ -1,8 +1,6 @@
import asyncio
import struct
from .constants import HEADER_TAGS
def encode_uvarint(number):
"""Pack `number` into varint bytes"""
@ -44,15 +42,3 @@ async def decode_uvarint_from_stream(reader, timeout):
break
return result
def get_flag(initiator, action):
"""
get header flag based on action for mplex
:param action: action type in str
:return: int flag
"""
if initiator or HEADER_TAGS[action] == 0:
return HEADER_TAGS[action]
return HEADER_TAGS[action] - 1