From 46087533841771c48ed724a61816b2b9b6b72cef Mon Sep 17 00:00:00 2001 From: Veselin Penev Date: Sun, 28 Apr 2024 22:55:54 +0200 Subject: [PATCH] few more fixes --- bitdust/blockchain/bismuth_pool.py | 7 ++++- bitdust/blockchain/blockchain_explorer.py | 28 ++++++++++++++++--- bitdust/customer/fire_hire.py | 3 +- .../services/service_customer_contracts.py | 3 +- .../services/service_supplier_contracts.py | 6 ++-- bitdust/supplier/storage_contract.py | 5 ++-- bitdust/userid/identity.py | 3 +- 7 files changed, 43 insertions(+), 12 deletions(-) diff --git a/bitdust/blockchain/bismuth_pool.py b/bitdust/blockchain/bismuth_pool.py index 71973b206..a00075b4f 100644 --- a/bitdust/blockchain/bismuth_pool.py +++ b/bitdust/blockchain/bismuth_pool.py @@ -599,6 +599,7 @@ def worker(s_time): class TCPHandler(socketserver.BaseRequestHandler): + def handle(self): global new_diff global node_ip @@ -615,7 +616,11 @@ def handle(self): peer_ip, peer_port = self.request.getpeername() try: - data = connections.receive(self.request, 10) + try: + data = connections.receive(self.request, 10) + except: + data = '' + lg.warn('failed reading data from %r: %r' % (self.client_address, self.request)) # if _Debug: # lg.args(_DebugLevel, data=data, peer_ip=peer_ip, peer_port=peer_port) diff --git a/bitdust/blockchain/blockchain_explorer.py b/bitdust/blockchain/blockchain_explorer.py index 2494c9516..9bba5b8c6 100644 --- a/bitdust/blockchain/blockchain_explorer.py +++ b/bitdust/blockchain/blockchain_explorer.py @@ -292,7 +292,7 @@ def render_GET(self, request): div_main_class='main blockchain', div_main_body=src, google_analytics='', - pre_footer=web_html_template.pre_footer % dict(basepath='https://%s/' % _ExplorerHost), + pre_footer='', ) return strng.to_bin(html_src) @@ -331,7 +331,7 @@ def render_GET(self, request): div_main_class='main blockchain-transaction', div_main_body=src, google_analytics='', - pre_footer=web_html_template.pre_footer % dict(basepath='https://%s/' % _ExplorerHost), + pre_footer='', ) return strng.to_bin(html_src) @@ -360,7 +360,27 @@ def render_GET(self, request): div_main_class='main blockchain-transaction', div_main_body=src, google_analytics='', - pre_footer=web_html_template.pre_footer % dict(basepath='https://%s/' % _ExplorerHost), + pre_footer='', + ) + return strng.to_bin(html_src) + + if not raw: + src += '

invalid transaction ID

\n' + src += '\n' + src += '\n' + src += '\n' + src += '\n' + html_src = web_html_template.WEB_ROOT_TEMPLATE % dict( + title='BitDust blockchain explorer', + site_url='https://bitdust.io', + basepath='https://%s/' % _ExplorerHost, + wikipath='https://bitdust.io/wiki/', + idserverspath='https://identities.bitdust.io/', + blockchainpath='https://blockchain.bitdust.io/', + div_main_class='main blockchain-transaction', + div_main_body=src, + google_analytics='', + pre_footer='', ) return strng.to_bin(html_src) @@ -390,7 +410,7 @@ def render_GET(self, request): div_main_class='main blockchain-transaction', div_main_body=src, google_analytics='', - pre_footer=web_html_template.pre_footer % dict(basepath='https://%s/' % _ExplorerHost), + pre_footer='', ) return strng.to_bin(html_src) diff --git a/bitdust/customer/fire_hire.py b/bitdust/customer/fire_hire.py index 89962f1fb..d8ef9f962 100644 --- a/bitdust/customer/fire_hire.py +++ b/bitdust/customer/fire_hire.py @@ -104,7 +104,7 @@ #------------------------------------------------------------------------------ _Debug = False -_DebugLevel = 14 +_DebugLevel = 12 #------------------------------------------------------------------------------ @@ -223,6 +223,7 @@ def Destroy(): class FireHire(automat.Automat): + """ This class implements all the functionality of the ``fire_hire()`` state machine. diff --git a/bitdust/services/service_customer_contracts.py b/bitdust/services/service_customer_contracts.py index 8ecdc733c..15de88c86 100644 --- a/bitdust/services/service_customer_contracts.py +++ b/bitdust/services/service_customer_contracts.py @@ -55,7 +55,8 @@ def start(self): return True def stop(self): - self.payment_loop.stop() + if self.payment_loop.running: + self.payment_loop.stop() self.payment_loop = None return True diff --git a/bitdust/services/service_supplier_contracts.py b/bitdust/services/service_supplier_contracts.py index cd296b90d..5b9f7b81a 100644 --- a/bitdust/services/service_supplier_contracts.py +++ b/bitdust/services/service_supplier_contracts.py @@ -57,9 +57,11 @@ def start(self): return True def stop(self): - self.accept_payments_loop.stop() + if self.accept_payments_loop.running: + self.accept_payments_loop.stop() self.accept_payments_loop = None - self.sync_my_transactions_loop.stop() + if self.sync_my_transactions_loop.running: + self.sync_my_transactions_loop.stop() self.sync_my_transactions_loop = None return True diff --git a/bitdust/supplier/storage_contract.py b/bitdust/supplier/storage_contract.py index 6fb6337ec..403d93ca5 100644 --- a/bitdust/supplier/storage_contract.py +++ b/bitdust/supplier/storage_contract.py @@ -505,6 +505,7 @@ def accept_storage_payments(): tx = jsn.loads_text(local_fs.ReadTextFile(filepath)) int(tx['block_height']) tx['operation'] + float(tx['amount']) except: lg.exc() continue @@ -523,11 +524,11 @@ def accept_storage_payments(): continue if customer_prefix not in my_storage_transactions: my_storage_transactions[customer_prefix] = { - 'total_amount': 0, + 'total_amount': 0.0, 'transactions': [], } my_storage_transactions[customer_prefix]['transactions'].append(tx) - my_storage_transactions[customer_prefix]['total_amount'] += tx['amount'] + my_storage_transactions[customer_prefix]['total_amount'] += float(tx['amount']) for customer_idurl in contactsdb.customers(): contracts_list = list_customer_contracts(customer_idurl) for contract_started_time in contracts_list.keys(): diff --git a/bitdust/userid/identity.py b/bitdust/userid/identity.py index 45299a32f..a7515670c 100644 --- a/bitdust/userid/identity.py +++ b/bitdust/userid/identity.py @@ -188,6 +188,7 @@ class identity(object): + """ We are passed an XML version of an identity and make an Identity. Also can construct an Identity by providing all fields. The fields is: @@ -411,7 +412,7 @@ def unserialize(self, xmlsrc): try: doc = minidom.parseString(strng.to_bin(xmlsrc)) except: - lg.exc('xmlsrc=%r' % xmlsrc) + lg.warn('failed reading identity source from %d bytes' % len(strng.to_bin(xmlsrc))) return self.clear_data() self.from_xmlobj(doc.documentElement)