ex 3
This commit is contained in:
parent
cb70a03d81
commit
4db46705fb
@ -1,8 +1,7 @@
|
|||||||
|
|
||||||
from SocketUtil import *
|
from SocketUtil import *
|
||||||
import TxBlock as Tx
|
from TxBlock import TxBlock
|
||||||
# import Tx
|
from Transaction import Tx
|
||||||
|
|
||||||
SERVER = 'localhost'
|
SERVER = 'localhost'
|
||||||
|
|
||||||
wallet_list = [SERVER]
|
wallet_list = [SERVER]
|
||||||
@ -14,6 +13,7 @@ def minerServer(my_ip, wallet_list):
|
|||||||
# receive 2 transactions
|
# receive 2 transactions
|
||||||
for i in range(10):
|
for i in range(10):
|
||||||
newTx = recvObj(miner_server_socket)
|
newTx = recvObj(miner_server_socket)
|
||||||
|
print(len(newTx))
|
||||||
if isinstance(newTx, Tx):
|
if isinstance(newTx, Tx):
|
||||||
tx_list.append(newTx)
|
tx_list.append(newTx)
|
||||||
print("Received Tx")
|
print("Received Tx")
|
||||||
@ -78,7 +78,7 @@ def minerServer(my_ip, wallet_list):
|
|||||||
block.find_nonce()
|
block.find_nonce()
|
||||||
# send that block to each in wallet_list
|
# send that block to each in wallet_list
|
||||||
for wallet in wallet_list:
|
for wallet in wallet_list:
|
||||||
sendObj(wallet, block)
|
sendObj(wallet, block, 5006)
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ from Transaction import *
|
|||||||
from Signature import *
|
from Signature import *
|
||||||
|
|
||||||
M_SERVER_IP = 'localhost'
|
M_SERVER_IP = 'localhost'
|
||||||
M_SERVER_PORT = 5005
|
M_SERVER_PORT = 5050
|
||||||
|
|
||||||
W_SERVER_IP = 'localhost'
|
W_SERVER_IP = 'localhost'
|
||||||
W_SERVER_PORT = 5006
|
W_SERVER_PORT = 5006
|
||||||
@ -31,7 +31,7 @@ print(Tx1.is_valid())
|
|||||||
print(Tx2.is_valid())
|
print(Tx2.is_valid())
|
||||||
|
|
||||||
try:
|
try:
|
||||||
sendObj(M_SERVER_IP, Tx1, M_SERVER_PORT)
|
# sendObj(M_SERVER_IP, Tx1, M_SERVER_PORT)
|
||||||
print("Sent Tx1")
|
print("Sent Tx1")
|
||||||
sendObj(M_SERVER_IP, Tx2, M_SERVER_PORT)
|
sendObj(M_SERVER_IP, Tx2, M_SERVER_PORT)
|
||||||
print("Sent Tx2")
|
print("Sent Tx2")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user