forked from LBRYCommunity/lbry-sdk
use more readable KB, MB
This commit is contained in:
parent
d06c670a12
commit
0036685ece
2 changed files with 13 additions and 9 deletions
|
@ -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"
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue