From 7dd5bc92f0d5d4315554f3962fa981772b887e4c Mon Sep 17 00:00:00 2001
From: Moul <moul@moul.re>
Date: Sun, 2 May 2021 16:20:23 +0200
Subject: [PATCH] [mod] #396: Remove client.close() now in DuniterPy

---
 silkaj/blocks.py     | 3 ---
 silkaj/cert.py       | 2 --
 silkaj/commands.py   | 6 ------
 silkaj/membership.py | 2 --
 silkaj/money.py      | 2 --
 silkaj/tui.py        | 4 +---
 silkaj/tx.py         | 6 ------
 silkaj/tx_history.py | 1 -
 silkaj/wot.py        | 4 ----
 9 files changed, 1 insertion(+), 29 deletions(-)

diff --git a/silkaj/blocks.py b/silkaj/blocks.py
index 236d914f..e6c8fff0 100644
--- a/silkaj/blocks.py
+++ b/silkaj/blocks.py
@@ -54,7 +54,6 @@ def verify_blocks_signatures(from_block, to_block):
                 block = Block.from_signed_raw(block["raw"] + block["signature"] + "\n")
                 verify_block_signature(invalid_blocks_signatures, block)
 
-    client.close()
     display_result(from_block, to_block, invalid_blocks_signatures)
 
 
@@ -63,13 +62,11 @@ def check_passed_blocks_range(client, from_block, to_block):
     if to_block == 0:
         to_block = head_number
     if to_block > head_number:
-        client.close()
         message_exit(
             "Passed TO_BLOCK argument is bigger than the head block: "
             + str(head_number)
         )
     if from_block > to_block:
-        client.close()
         message_exit("TO_BLOCK should be bigger or equal to FROM_BLOCK")
     return to_block
 
diff --git a/silkaj/cert.py b/silkaj/cert.py
index 1d967848..5c167466 100644
--- a/silkaj/cert.py
+++ b/silkaj/cert.py
@@ -85,8 +85,6 @@ def send_certification(ctx, uid_pubkey_to_certify):
     else:
         print("Error while publishing certification: {0}".format(response.text()))
 
-    client.close()
-
 
 def pre_checks(client, issuer_pubkey, pubkey_to_certify):
     # Check whether current user is member
diff --git a/silkaj/commands.py b/silkaj/commands.py
index b83608a2..16fec63e 100644
--- a/silkaj/commands.py
+++ b/silkaj/commands.py
@@ -56,8 +56,6 @@ def currency_info():
         "\nDifference time:",
         current_time.diff_for_humans(mediantime, True),
     )
-    client = ClientInstance().client
-    client.close()
 
 
 def match_pattern(pow, match="", p=1):
@@ -93,7 +91,6 @@ def difficulties():
             jsonschema.validate(current, bma.ws.WS_BLOCK_SCHEMA)
             diffi = client(bma.blockchain.difficulties)
             display_diffi(current, diffi)
-        client.close()
     except jsonschema.ValidationError as e:
         print("{:}:{:}".format(str(e.__class__.__name__), str(e)))
 
@@ -169,7 +166,6 @@ def list_blocks(number, detailed):
             ):
                 issuer2["uid"] = idty["uid"]
                 issuer2.pop("pubkey")
-    client.close()
     print(
         "Last {0} blocks from n°{1} to n°{2}".format(
             number, current_nbr - number + 1, current_nbr
@@ -249,5 +245,3 @@ def argos_info():
         "\nDifference time:",
         current_time.diff_for_humans(mediantime, True),
     )
-    client = ClientInstance().client
-    client.close()
diff --git a/silkaj/membership.py b/silkaj/membership.py
index 453628c2..e62302ec 100644
--- a/silkaj/membership.py
+++ b/silkaj/membership.py
@@ -74,7 +74,6 @@ def send_membership(ctx):
 
     if dry_run:
         click.echo(membership.signed_raw())
-        client.close()
         sys.exit(SUCCESS_EXIT_STATUS)
 
     if ctx.obj["DISPLAY_DOCUMENT"]:
@@ -89,7 +88,6 @@ def send_membership(ctx):
     else:
         print("Error while publishing membership: {0}".format(response.text()))
     logging.debug(response.text())
-    client.close()
 
 
 def display_confirmation_table(identity_uid, pubkey, identity_timestamp):
diff --git a/silkaj/money.py b/silkaj/money.py
index e9007b47..6e3dcfb7 100644
--- a/silkaj/money.py
+++ b/silkaj/money.py
@@ -35,7 +35,6 @@ from silkaj.tui import display_amount, display_pubkey_and_checksum
 @argument("pubkeys", nargs=-1)
 @pass_context
 def cmd_amount(ctx, pubkeys):
-    client = ClientInstance().client
     if not has_auth_method():
 
         # check input pubkeys
@@ -68,7 +67,6 @@ def cmd_amount(ctx, pubkeys):
         key = auth_method()
         pubkey = key.pubkey
         show_amount_from_pubkey(pubkey, get_amount_from_pubkey(pubkey))
-    client.close()
 
 
 def show_amount_from_pubkey(label, inputs_balance):
diff --git a/silkaj/tui.py b/silkaj/tui.py
index b98bdc9b..985c9745 100644
--- a/silkaj/tui.py
+++ b/silkaj/tui.py
@@ -20,7 +20,7 @@ import click
 
 from silkaj import constants
 from silkaj import crypto_tools as ct
-from silkaj import network_tools, wot_tools
+from silkaj import wot_tools
 
 
 def display_amount(tx, message, amount, ud_value, currency_symbol):
@@ -64,6 +64,4 @@ def display_pubkey_and_checksum(
 
 def send_doc_confirmation(document_name):
     if not click.confirm(f"Do you confirm sending this {document_name}?"):
-        client = network_tools.ClientInstance().client
-        client.close()
         sys.exit(constants.SUCCESS_EXIT_STATUS)
diff --git a/silkaj/tx.py b/silkaj/tx.py
index 6ba18b46..466d3fb1 100644
--- a/silkaj/tx.py
+++ b/silkaj/tx.py
@@ -167,9 +167,6 @@ def send_transaction(
             comment,
             outputbackchange,
         )
-    else:
-        client = nt.ClientInstance().client
-        client.close()
 
 
 def transaction_amount(amounts, UDs_amounts, outputAddresses):
@@ -332,8 +329,6 @@ def handle_intermediaries_transactions(
     Comment="",
     OutputbackChange=None,
 ):
-    client = nt.ClientInstance().client
-
     while True:
         # consider there is always one backchange output, hence +1
         listinput_and_amount = get_list_input_for_transaction(
@@ -361,7 +356,6 @@ def handle_intermediaries_transactions(
                 Comment,
                 OutputbackChange,
             )
-            client.close()
             break
 
 
diff --git a/silkaj/tx_history.py b/silkaj/tx_history.py
index e9ae0d6e..da974218 100644
--- a/silkaj/tx_history.py
+++ b/silkaj/tx_history.py
@@ -53,7 +53,6 @@ def transaction_history(pubkey, uids, full_pubkey):
     )
     table = Texttable(max_width=shutil.get_terminal_size().columns)
     table.add_rows(txs_list)
-    client.close()
     echo_via_pager(header + table.draw())
 
 
diff --git a/silkaj/wot.py b/silkaj/wot.py
index eb96533d..5fbfb80d 100644
--- a/silkaj/wot.py
+++ b/silkaj/wot.py
@@ -102,7 +102,6 @@ def received_sent_certifications(uid_pubkey):
         )
     )
     membership_status(certifications, pubkey, req)
-    client.close()
 
 
 def cert_written_in_the_blockchain(written_certs, certifieur):
@@ -156,10 +155,7 @@ def id_pubkey_correspondence(uid_pubkey):
     if checked_pubkey:
         uid_pubkey = checked_pubkey
 
-    client = ClientInstance().client
     lookups = wt.wot_lookup(uid_pubkey)
-    await client.close()
-
     content = f"Public keys or user id found matching '{uid_pubkey}':\n"
     for lookup in lookups:
         for identity in lookup["uids"]:
-- 
GitLab