-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSampleClient.py
More file actions
53 lines (38 loc) · 1.11 KB
/
SampleClient.py
File metadata and controls
53 lines (38 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import signal
from time import sleep
import json
from core.client_core import ClientCore
from p2p.message_manager import MSG_NEW_TRANSACTION
my_p2p_client = None
def signal_handler(signal, frame):
shutdown_client()
def shutdown_client():
global my_p2p_client
my_p2p_client.shutdown()
def main():
signal.signal(signal.SIGINT, signal_handler)
global my_p2p_client
my_p2p_client = ClientCore(50100, '192.168.10.104', 50082)
my_p2p_client.start()
sleep(10)
transaction = {
'sender': 'test4',
'recipient': 'test5',
'value': 3
}
my_p2p_client.send_message_to_my_core_node(MSG_NEW_TRANSACTION, json.dumps(transaction))
transaction2 = {
'sender': 'test6',
'recipient': 'test7',
'value': 2
}
my_p2p_client.send_message_to_my_core_node(MSG_NEW_TRANSACTION, json.dumps(transaction2))
sleep(10)
transaction3 = {
'sender': 'test8',
'recipient': 'test9',
'value': 10
}
my_p2p_client.send_message_to_my_core_node(MSG_NEW_TRANSACTION, json.dumps(transaction3))
if __name__ == '__main__':
main()