#FIXME: change the parameter type to uint64 and return to uint16 proc encodeRemainingLength*(length: uint64): uint64 = var length = length var endocedLength: uint64 = 0 while true: endocedLength = length mod 128'u64 length = length div 128 if length > 0'u64: endocedLength = endocedLength or 128 else: break result = endocedLength