Skip to content
Snippets Groups Projects
Commit 87fcbb86 authored by Pascal Engélibert's avatar Pascal Engélibert :bicyclist:
Browse files

Standardize function names

parent bb015a71
No related branches found
No related tags found
No related merge requests found
Pipeline #5634 passed
......@@ -253,17 +253,17 @@ def mix(db_txs, amount, base, sender, path, host, proxy=None, proxy_onion_only=F
if send_tx:
try:
sendTransaction(sender, path[0], amount, gen_comment(comment_seeds[0]))
send_transaction(sender, path[0], amount, gen_comment(comment_seeds[0]))
message["sent"] = True
db_txs.put(comment_seeds[0][1], PublicKey(sender.pubkey).encrypt_seal(ubjson.dumpb(message)))
except socket.timeout:
logPrint("Error when sending tx: timeout", LOG_ERROR)
logprint("Error when sending tx: timeout", LOG_ERROR)
except Exception as e:
logPrint("Error when sending tx: " + str(e), LOG_ERROR)
logprint("Error when sending tx: " + str(e), LOG_ERROR)
return
async def test1(db_txs, host, receiver, amount=1000, layers=3, proxy=None, proxy_onion_only=False, send_tx=True):
async def main(db_txs, host, receiver, amount=1000, layers=3, proxy=None, proxy_onion_only=False, send_tx=True):
if amount < 100:
print("!! Warning !!\nYou are going to send less than 1.00, all this money will be destroyed by Duniter.\nPlease always send 1.00 or more.")
if input("Do it anyway? [yn]: ").lower() != "y":
......@@ -337,4 +337,4 @@ python3 client.py -h svetsae7j3usrycn.onion 10951 -r 78ZwwgpgdH5uLZLbThUQH7LKwPg
db_txs = plyvel.DB(DIR+"/client_db_txs", create_if_missing=True)
asyncio.get_event_loop().run_until_complete(test1(db_txs, (host, port), receiver, amount, layers, proxy, proxy_onion_only, send_tx))
asyncio.get_event_loop().run_until_complete(main(db_txs, (host, port), receiver, amount, layers, proxy, proxy_onion_only, send_tx))
This diff is collapsed.
......@@ -109,7 +109,7 @@ LOG_ERROR = 8
LOGMSG_TYPES = {LOG_INFO:"\033[96minfo\033[0m", LOG_TRACE:"\033[39mtrace\033[0m", LOG_WARN:"\033[93mwarn\033[0m", LOG_ERROR:"\033[91merror\033[0m"}
VERBOSITY = LOG_INFO | LOG_WARN | LOG_ERROR
def logPrint(msg:str, msgtype:int):
def logprint(msg:str, msgtype:int):
if msgtype & VERBOSITY:
print(time.strftime("%Y-%m-%d %H:%M:%S")+" ["+LOGMSG_TYPES[msgtype]+"] "+msg)
......@@ -138,7 +138,7 @@ class Peer:
return self.pubkey + " " + self.host + " " + str(self.port)
# Read peers list
def readPeers(cdir:str) -> (list, dict):
def read_peers(cdir:str) -> (list, dict):
if not os.path.isfile(cdir+"/peers"):
open(cdir+"/peers", "w").close()
......@@ -158,13 +158,13 @@ def readPeers(cdir:str) -> (list, dict):
return peers, peers_index
# Save peers list
def writePeers(cdir:str, peers:list):
def write_peers(cdir:str, peers:list):
peersfile = open(cdir+"/peers", "w")
for peer in peers:
peersfile.write(peer.export_str()+"\n")
peersfile.close()
def sendTransaction(sender_keys:SigningKey, receiver_pubkey:str, amount:int, comment:str):
def send_transaction(sender_keys:SigningKey, receiver_pubkey:str, amount:int, comment:str):
sender_amount = silkaj.money.get_amount_from_pubkey(sender_keys.pubkey)[0]
assert sender_amount >= amount, "not enough money"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment