Commit 8cebdbb6 authored by matograine's avatar matograine

working retrieving tx with more than 20 sources

parent 927ba040
......@@ -26,6 +26,7 @@ from utils.silkaj.tools import coroutine
import os
import json
MAX_ISSUERS = 20
class Retrieve():
......@@ -42,18 +43,50 @@ class Retrieve():
## 2e essai
@coroutine
async def retrieve(self, file, retrieving_pubkeys):
retrieving_pubkeys = retrieving_pubkeys.split(":")
async def retrieve(self, file, retrieving_pubkey):
with open(file) as wallets_json:
retrieving_wallets = json.load(wallets_json)
#retrieving_wallets = open_file(file)
issuers_keys = Retrieve.get_key_list(retrieving_wallets)
print ("DEBUG : " + str(len(retrieving_wallets)))
while len(retrieving_wallets) != 0:
issuers, key_list, amount, listinput = list(), list(), 0, list()
wallet_list = list()
for n in range (0,MAX_ISSUERS):
wallet_list.append (retrieving_wallets[n])
issuers_keys = Retrieve.get_key_list(wallet_list)
#créer les listes : clefs, issuers, amount
# while a < len(issuers_keys):
for a in range (0, len(issuers_keys)):
key_list.append(issuers_keys[a])
issuers.append(issuers_keys[a].pubkey)
listinput_and_amount = await get_list_input_for_transaction(a, issuers_keys[a].pubkey, len(listinput))
listinput.extend(listinput_and_amount[0])
amount = amount + listinput_and_amount[1]
intermediatetransaction = listinput_and_amount[2]
# eventuellement pop() les pubkeys vides ici ?
if intermediatetransaction or issuers_keys[a] == issuers_keys[-1] :
total_listinput_and_amount = [listinput, amount, intermediatetransaction]
amount = [amount]
await generate_and_send_transaction(
key_list,
issuers,
amount,
total_listinput_and_amount,
[retrieving_pubkey],
"",
)
issuers, key_list, amount, listinput = list(), list(), 0, list()
for n in range (0,MAX_ISSUERS):
retrieving_wallets.pop(0)
# closing the client instance
await ClientInstance().client.close()
"""
#créer les listes : clefs, issuers, amount
issuers, key_list, amount, listinput = list(), list(), 0, list()
a = 0
while a < len(issuers_keys):
# for key in issuers_keys:
key_list.append(issuers_keys[a])
issuers.append(issuers_keys[a].pubkey)
listinput_and_amount = await get_list_input_for_transaction(a, issuers_keys[a].pubkey, len(listinput))
......@@ -74,8 +107,10 @@ class Retrieve():
)
issuers, key_list, amount, listinput = list(), list(), 0, list()
a = a+1
"""
### pour mémoire
"""
"""
def retrieve(file, retrieving_pubkeys):
retrieving_pubkeys = retrieving_pubkeys.split(":")
retrieving_wallets = open(file)
......@@ -109,4 +144,4 @@ class Retrieve():
)
def count(issuers_keys):
"""
"""
......@@ -378,7 +378,7 @@ async def generate_and_send_transaction(
if response.status == 200:
print("Transaction successfully sent.")
else:
message_exit(
print(
"Error while publishing transaction: {0}".format(await response.text())
)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment