2
2
3
3
from ipycanvas import hold_canvas
4
4
5
- from algorithms .single_client_total_replication import SingleClientTotalReplication
5
+ from algorithms .single_client_versioned_majority import SingleClientVersionedMajority
6
6
from engine .client import ClientFactory , Client , ClientType
7
7
from engine .consistency_checker import ConsistencyChecker
8
8
from engine .gateway import Gateway
@@ -19,7 +19,7 @@ def run(client_count, nodes_count, background, nodes_layer, signals_layer):
19
19
ratio = int (simulator_timer_interval // draw_timer_interval )
20
20
21
21
gateway = Gateway (server_id = "gateway" , timer = Timer ())
22
- node_factory = NodeFactory (SingleClientTotalReplication , gateway )
22
+ node_factory = NodeFactory (SingleClientVersionedMajority , gateway )
23
23
client_factory = ClientFactory (gateway )
24
24
25
25
nodes = []
@@ -28,7 +28,7 @@ def run(client_count, nodes_count, background, nodes_layer, signals_layer):
28
28
29
29
clients = []
30
30
for i in range (0 , client_count ):
31
- clients .append (client_factory .add_client (client_type = ClientType . Write ))
31
+ clients .append (client_factory .add_client ())
32
32
33
33
simulator = SimulatorLoop (
34
34
timer = Timer (),
@@ -66,10 +66,7 @@ def draw_signals(object_positions, signals, draw_progress, canvas):
66
66
# This will not work with both clients and nodes
67
67
# canvas.translate(canvas.width // 2, canvas.height // 4)
68
68
for s in signals :
69
- if (
70
- s .from_node not in object_positions
71
- or s .to_node not in object_positions
72
- ):
69
+ if s .from_node not in object_positions or s .to_node not in object_positions :
73
70
continue
74
71
draw_signal (
75
72
canvas ,
@@ -87,15 +84,11 @@ def draw_nodes(clients, nodes, gateway, canvas):
87
84
object_positions = {}
88
85
89
86
for idx , c in enumerate (clients ):
90
- object_positions [c .id ] = draw_client (
91
- canvas , idx , c .id , len (clients )
92
- )
87
+ object_positions [c .id ] = draw_client (canvas , idx , c .id , len (clients ))
93
88
object_positions [gateway .id ] = draw_gateway (canvas )
94
89
95
90
# canvas.translate(canvas.width // 2, canvas.height // 4)
96
91
center = (canvas .width // 2 , canvas .height // 4 )
97
92
for idx , n in enumerate (nodes ):
98
- object_positions [n .id ] = draw_node (
99
- canvas , center , idx , n .id , len (nodes )
100
- )
93
+ object_positions [n .id ] = draw_node (canvas , center , idx , n .id , len (nodes ))
101
94
return object_positions
0 commit comments