-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
47 lines (31 loc) · 1.23 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
from network.NodeNetworking import NodeNetworking
from database.KnownNodesHandler import KnownNodesHandler
from engine.MessageGenerator import MessageGenerator
from config import *
from object.Block import *
from Miner import Miner
from utility.other_utilities import *
from database.UTXO import UTXO
def main():
mode = "testing" # "testing", "production" or "grading"
ObjectHandler.start_auto_save()
TimeTracker.regularly_print_stats()
if mode == "grading":
reset_objects_file() # makes it easier to debug fetching the chaintip
KnownNodesHandler.clear_known_nodes()
if mode == "production":
KnownNodesHandler.load_known_nodes()
ObjectHandler.load_objects()
ObjectHandler.update_id_to_index()
if mode == "testing":
reset_objects_file()
KnownNodesHandler.add_node(BOOTSTRAP_NODE)
# Let user change agent_name if it is the default
if MessageGenerator.agent_name == "THIS COULD BE YOUR NODE":
MessageGenerator.agent_name = input("Enter a name for your node: ")
KnownNodesHandler.set_active_nodes()
ObjectHandler.load_objects()
ObjectHandler.update_id_to_index()
NodeNetworking.start_server()
if __name__ == "__main__":
main()