Compare commits

...
7 Commits
Author SHA1 Message Date
Victor Shyba c6419f199c wip patch 2020-05-26 14:12:47 -03:00
Victor Shyba 5a3cd577db log before processing, after server reply 2020-05-23 01:27:28 -03:00
Victor Shyba f5ccb8efdc more logs 2020-05-20 23:19:08 -03:00
Lex Berezhny 46ef6c8ab7 Merge pull request #2947 from thebubbleindex/patch-1
properly handle integer environment values, fixes issue with specifying ports via environment vars
2020-05-18 11:11:10 -04:00
Lex Berezhny b09eabc478 minor simplifcation 2020-05-18 08:53:34 -04:00
thebubbleindex e49fcea6e3 fix issue with specifying ports via env vars
make sure tcp and udp port for dht are int type
2020-05-18 08:53:07 -04:00
Jack Robison 26964ecf0f fix download_blob_from_peer.py 2020-05-13 09:24:35 -04:00
5 changed files with 28 additions and 6 deletions

No files matched your search

+14 -5
View File
@@ -277,14 +277,23 @@ class Strings(ListSetting):
class EnvironmentAccess:
PREFIX = 'LBRY_'
def __init__(self, environ: dict):
self.environ = environ
def __init__(self, config: 'BaseConfig', environ: dict):
self.configuration = config
self.data = {}
if environ:
self.load(environ)
def load(self, environ):
for setting in self.configuration.get_settings():
value = environ.get(f'{self.PREFIX}{setting.name.upper()}', NOT_SET)
if value != NOT_SET and not (isinstance(setting, ListSetting) and value is None):
self.data[setting.name] = setting.deserialize(value)
def __contains__(self, item: str):
return f'{self.PREFIX}{item.upper()}' in self.environ
return item in self.data
def __getitem__(self, item: str):
return self.environ[f'{self.PREFIX}{item.upper()}']
return self.data[item]
class ArgumentAccess:
@@ -443,7 +452,7 @@ class BaseConfig:
self.arguments = ArgumentAccess(self, args)
def set_environment(self, environ=None):
self.environment = EnvironmentAccess(environ or os.environ)
self.environment = EnvironmentAccess(self, environ or os.environ)
def set_persisted(self, config_file_path=None):
if config_file_path is None:
+6 -1
View File
@@ -483,6 +483,7 @@ class Ledger(metaclass=LedgerRegistry):
def process_status_update(self, update):
address, remote_status = update
log.info("Server sent update for %s, processing.", address)
self._update_tasks.add(self.update_history(address, remote_status))
async def update_history(self, address, remote_status, address_manager: AddressManager = None):
@@ -640,6 +641,7 @@ class Ledger(metaclass=LedgerRegistry):
return self.network.broadcast(hexlify(tx.raw).decode())
async def wait(self, tx: Transaction, height=-1, timeout=1):
log.info("waiting for tx %s with timeout %s seconds", tx.id, timeout)
timeout = timeout or 600 # after 10 minutes there is almost 0 hope
addresses = set()
for txi in tx.inputs:
@@ -653,6 +655,7 @@ class Ledger(metaclass=LedgerRegistry):
start = int(time.perf_counter())
while timeout and (int(time.perf_counter()) - start) <= timeout:
if await self._wait_round(tx, height, addresses):
log.info("got reply for tx %s with timeout %s seconds", tx.id, timeout)
return
raise asyncio.TimeoutError('Timed out waiting for transaction.')
@@ -675,7 +678,9 @@ class Ledger(metaclass=LedgerRegistry):
if txid == tx.id and local_height >= height:
found = True
if not found:
log.debug("timeout: %s, %s, %s", record['history'], addresses, tx.id)
log.info('forcing update on %s', record['address'])
self._update_tasks.add(self.update_history(record['address'], 'force'))
log.info("timeout: %s, %s, %s", record['history'], addresses, tx.id)
return False
return True
+2
View File
@@ -298,7 +298,9 @@ class WalletManager:
async def broadcast_or_release(self, tx, blocking=False):
try:
log.info("broadcasting %s", tx.id)
await self.ledger.broadcast(tx)
log.info("broadcasted %s", tx.id)
if blocking:
await self.ledger.wait(tx, timeout=None)
except:
+1
View File
@@ -3,6 +3,7 @@ import os
import asyncio
import socket
import ipaddress
import lbry.wallet
from lbry.conf import Config
from lbry.extras.daemon.storage import SQLiteStorage
from lbry.blob.blob_manager import BlobManager
+5
View File
@@ -90,10 +90,15 @@ class ConfigurationTests(unittest.TestCase):
def test_environment(self):
c = TestConfig()
self.assertEqual(c.test_str, 'the default')
c.set_environment({'LBRY_TEST_STR': 'from environ'})
self.assertEqual(c.test_str, 'from environ')
self.assertEqual(c.test_int, 9)
c.set_environment({'LBRY_TEST_INT': '1'})
self.assertEqual(c.test_int, 1)
def test_persisted(self):
with tempfile.TemporaryDirectory() as temp_dir: