-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
71 lines (50 loc) · 1.39 KB
/
main.py
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
54
55
56
57
58
59
60
61
62
63
64
65
66
from LogCollector.grabber import start_monitor
from time import sleep
from threading import Thread
from SmartContract.read import read
from SmartContract.write import write
from os import system, path, _exit
from queue import Queue
import sys
def menu():
print("1) Start Mining")
print("2) Read Data From Blockchain")
print("3) Exit")
inp = int(input())
return inp
def mining():
q = Queue()
t1 = Thread(target = start_monitor, args =(q, ))
t1.start()
while True:
if q:
write(ganache_url, path_to_abi, address, server_id, q)
print("Writing to Blockchain...")
def reading(count):
read(ganache_url, path_to_abi, address, server_id, count)
print("WELCOME TO LogChain!")
started = False
ganache_url = 'http://127.0.0.1:7545'
path_to_abi = path.abspath('abi.json')
address = "0xE971e88b6Cf30d21F1A62D6296ecf6D56924C5Ad"
server_id = 123
while True:
system('clear')
inp = menu()
if inp == 1 and started:
print("Mining already working.")
continue
if inp == 1:
print('Starting Mining')
t = Thread(target=mining)
t.start()
print('Mining Started')
started = True
sleep(4)
elif inp == 2:
count = int(input('Enter Number Of Records: '))
reading(count)
input()
else:
print('Exiting!')
_exit(1)