mirror of
https://github.com/varun-r-mallya/py-libp2p.git
synced 2025-12-31 20:36:24 +00:00
Refactor HeaderTags
This commit is contained in:
@ -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
|
||||
|
||||
Reference in New Issue
Block a user