From d98904a7871c9ea8d3fd99d86e8e09d39ab63a0b Mon Sep 17 00:00:00 2001 From: David Katz <15Dkatz@shcp.edu> Date: Thu, 26 Oct 2023 16:51:22 -0700 Subject: [PATCH] Address UUID requirement --- backend/app/__init__.py | 2 +- backend/pubsub.py | 3 ++- backend/wallet/wallet.py | 3 ++- requirements.txt | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/backend/app/__init__.py b/backend/app/__init__.py index ae3c254..2c37ce7 100644 --- a/backend/app/__init__.py +++ b/backend/app/__init__.py @@ -16,7 +16,7 @@ blockchain = Blockchain() wallet = Wallet(blockchain) transaction_pool = TransactionPool() -pubsub = PubSub(blockchain, transaction_pool) +pubsub = PubSub(blockchain, transaction_pool, wallet) @app.route('/') def route_default(): diff --git a/backend/pubsub.py b/backend/pubsub.py index 61f5e4a..8ef8e3b 100644 --- a/backend/pubsub.py +++ b/backend/pubsub.py @@ -48,7 +48,8 @@ class PubSub(): Handles the publish/subscribe layer of the application. Provides communication between the nodes of the blockchain network. """ - def __init__(self, blockchain, transaction_pool): + def __init__(self, blockchain, transaction_pool, wallet): + pnconfig.user_id = wallet.id self.pubnub = PubNub(pnconfig) self.pubnub.subscribe().channels(CHANNELS.values()).execute() self.pubnub.add_listener(Listener(blockchain, transaction_pool)) diff --git a/backend/wallet/wallet.py b/backend/wallet/wallet.py index 5801695..741208b 100644 --- a/backend/wallet/wallet.py +++ b/backend/wallet/wallet.py @@ -19,7 +19,8 @@ class Wallet: """ def __init__(self, blockchain=None): self.blockchain = blockchain - self.address = str(uuid.uuid4())[0:8] + self.id = str(uuid.uuid4()) + self.address = self.id[0:8] self.private_key = ec.generate_private_key( ec.SECP256K1(), default_backend() diff --git a/requirements.txt b/requirements.txt index 18be080..630ea17 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ pytest==5.1.2 Flask==1.1.1 -pubnub==4.1.6 +pubnub==7.3.0 requests==2.22.0 cryptography==2.7 Flask-Cors==3.0.8