From 0036685ecee7c1444ce23c04ec404c59b65cd0e0 Mon Sep 17 00:00:00 2001 From: Job Evers-Meltzer Date: Fri, 4 Nov 2016 11:36:43 -0500 Subject: [PATCH] use more readable KB, MB --- lbrynet/conf.py | 12 +++++++----- tests/mocks.py | 10 ++++++---- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/lbrynet/conf.py b/lbrynet/conf.py index 807f3cb0e..a3ccad693 100644 --- a/lbrynet/conf.py +++ b/lbrynet/conf.py @@ -14,6 +14,8 @@ log = logging.getLogger(__name__) LINUX = 1 DARWIN = 2 WINDOWS = 3 +KB = 2**10 +MB = 2**20 if sys.platform.startswith("darwin"): @@ -185,13 +187,13 @@ class AdjustableSettings(Setting): class ApplicationSettings(Setting): """Settings that are constants and shouldn't be overriden""" def __init__(self): - self.MAX_HANDSHAKE_SIZE = 2**16 - self.MAX_REQUEST_SIZE = 2**16 - self.MAX_BLOB_REQUEST_SIZE = 2**16 - self.MAX_RESPONSE_INFO_SIZE = 2**16 + self.MAX_HANDSHAKE_SIZE = 64*KB + self.MAX_REQUEST_SIZE = 64*KB + self.MAX_BLOB_REQUEST_SIZE = 64*KB + self.MAX_RESPONSE_INFO_SIZE = 64*KB self.MAX_BLOB_INFOS_TO_REQUEST = 20 self.BLOBFILES_DIR = "blobfiles" - self.BLOB_SIZE = 2**21 + self.BLOB_SIZE = 2*MB self.LOG_FILE_NAME = "lbrynet.log" self.LOG_POST_URL = "https://lbry.io/log-upload" self.CRYPTSD_FILE_EXTENSION = ".cryptsd" diff --git a/tests/mocks.py b/tests/mocks.py index c63827932..55c3ed45e 100644 --- a/tests/mocks.py +++ b/tests/mocks.py @@ -8,6 +8,8 @@ from lbrynet.core import PTCWallet from lbrynet.core import BlobAvailability +KB = 2**10 + class Node(object): def __init__(self, *args, **kwargs): pass @@ -129,12 +131,12 @@ class GenFile(io.RawIOBase): def readall(self): return self.read() - def _generate_chunk(self, n=2**10): - output = self.pattern[self.last_offset:self.last_offset + n] - n_left = n - len(output) + def _generate_chunk(self, size=KB): + output = self.pattern[self.last_offset:self.last_offset + size] + n_left = size - len(output) whole_patterns = n_left / len(self.pattern) output += self.pattern * whole_patterns - self.last_offset = n - len(output) + self.last_offset = size - len(output) output += self.pattern[:self.last_offset] return output