added exit function, changed notifications
This commit is contained in:
parent
f4a9c7ed2e
commit
e4642d7a30
@ -4,6 +4,7 @@ from classes.TxBlock import TxBlock
|
||||
|
||||
from helpers import DatabaseHelper as databaseHelper
|
||||
from helpers import UtilityHelper as utilityHelper
|
||||
from helpers import BlockHelper as blockHelper
|
||||
|
||||
import socket
|
||||
import pickle
|
||||
@ -59,7 +60,16 @@ def connection(ip, port, db):
|
||||
|
||||
if type(item) == TxBlock:
|
||||
print(f"{utilityHelper.blinkMessage('Received block from peer')}")
|
||||
utilityHelper.addFile("../data/ledger.dat", item)
|
||||
valid, exit = blockHelper.socketBlock(item)
|
||||
|
||||
if not valid:
|
||||
print(f"{utilityHelper.errorMessage('Received block is not valid')}")
|
||||
continue
|
||||
|
||||
if exit:
|
||||
print(f"{utilityHelper.errorMessage('Closing connection and application')}")
|
||||
exit()
|
||||
continue
|
||||
continue
|
||||
|
||||
# DATABASE STUFF
|
||||
@ -67,10 +77,12 @@ def connection(ip, port, db):
|
||||
match item[0]:
|
||||
|
||||
case "USER CREATE":
|
||||
print(f"{utilityHelper.blinkMessage('Received user from peer')}")
|
||||
db.createUser(item[1], item[2], item[3], item[4])
|
||||
continue
|
||||
|
||||
case "USER DELETE":
|
||||
print(f"{utilityHelper.blinkMessage('Peer deleted user')}")
|
||||
db.deleteUser(item[1])
|
||||
continue
|
||||
|
||||
@ -89,3 +101,9 @@ def connection(ip, port, db):
|
||||
case "UPDATE LOG STATUS":
|
||||
db.updateLogStatus(item[1])
|
||||
continue
|
||||
|
||||
if type(item) == str:
|
||||
match item:
|
||||
case "EXIT":
|
||||
exit()
|
||||
continue
|
Loading…
x
Reference in New Issue
Block a user