Skip to content

Commit ef8527c

Browse files
committed
Changes on the corrRNG example
1 parent c2a6df9 commit ef8527c

File tree

6 files changed

+46
-84
lines changed

6 files changed

+46
-84
lines changed

examples/nativeMode/corrRNG/README.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Bob to check whether the teleportation worked correctly.
1313

1414

1515
To start run:
16-
- simulaqron start --nodes=Alice,Bob --keep
16+
- simulaqron start --nodes=Alice,Bob --network-config-file classicalNet.json
1717

1818
sh run.sh
1919

examples/nativeMode/corrRNG/aliceTest.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
from simulaqron.local.setup import setup_local
3333
from simulaqron.general.host_config import SocketsConfig
34-
from simulaqron.settings import simulaqron_settings
34+
from simulaqron.settings import simulaqron_settings, network_config
3535
from twisted.internet.defer import inlineCallbacks
3636
from twisted.internet import reactor
3737
from twisted.spread import pb
@@ -117,11 +117,12 @@ def main():
117117

118118
myName = "Alice" # we are Alice
119119

120-
# This file defines the network of virtual quantum nodes
121-
virtualNet = SocketsConfig(str(simulaqron_settings.network_config_file), network_name="default", config_type="vnode")
120+
# This file defines the network of virtual quantum nodes and the network used for classical communication
121+
network_config.read_from_file("classicalNet.json")
122122

123-
# This file defines the network used for classical communication
124-
classicalNet = SocketsConfig("classicalNet.json", network_name="default", config_type="app")
123+
# Using the config, we then get the right sockets configuration type
124+
virtualNet = SocketsConfig(network_config, network_name="default", config_type="vnode")
125+
classicalNet = SocketsConfig(network_config, network_name="default", config_type="app")
125126

126127
# Check if we should run a server (if this node is listed in classicalNet)
127128
if myName in classicalNet.hostDict:

examples/nativeMode/corrRNG/bobTest.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
from simulaqron.local.setup import setup_local
3434
from simulaqron.general.host_config import SocketsConfig
35-
from simulaqron.settings import simulaqron_settings
35+
from simulaqron.settings import simulaqron_settings, network_config
3636
from twisted.internet.defer import inlineCallbacks
3737
from twisted.spread import pb
3838

@@ -130,11 +130,12 @@ def main():
130130

131131
logging.basicConfig(format='%(asctime)s:%(levelname)s:%(message)s', level=logging.DEBUG)
132132

133-
# This file defines the network of virtual quantum nodes
134-
virtualNet = SocketsConfig(str(simulaqron_settings.network_config_file), network_name="default", config_type="vnode")
133+
# This file defines the network of virtual quantum nodes and the network used for classical communication
134+
network_config.read_from_file("classicalNet.json")
135135

136-
# This file defines the network used for classical communication
137-
classicalNet = SocketsConfig("classicalNet.json", network_name="default", config_type="app")
136+
# Using the config, we then get the right sockets configuration type
137+
virtualNet = SocketsConfig(network_config, network_name="default", config_type="vnode")
138+
classicalNet = SocketsConfig(network_config, network_name="default", config_type="app")
138139

139140
# Check if we should run a server (if this node is listed in classicalNet)
140141
if myName in classicalNet.hostDict:
Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
1-
{
2-
"default": {
3-
"nodes": {
4-
"Alice": {
5-
"app_socket": ["localhost", 8821],
6-
"qnodeos_socket": ["localhost", 8822],
7-
"vnode_socket": ["localhost", 8823]
1+
[
2+
{
3+
"name": "default",
4+
"nodes": [
5+
{
6+
"Alice": {
7+
"app_socket": ["localhost", 8821],
8+
"qnodeos_socket": ["localhost", 8822],
9+
"vnode_socket": ["localhost", 8823]
10+
}
811
},
9-
"Bob": {
10-
"app_socket": ["localhost", 8831],
11-
"qnodeos_socket": ["localhost", 8832],
12-
"vnode_socket": ["localhost", 8833]
12+
{
13+
"Bob": {
14+
"app_socket": ["localhost", 8831],
15+
"qnodeos_socket": ["localhost", 8832],
16+
"vnode_socket": ["localhost", 8833]
17+
}
1318
}
14-
},
19+
],
1520
"topology": null
1621
}
17-
}
22+
]

examples/nativeMode/corrRNG/terminate.sh

100644100755
File mode changed.

simulaqron/_default_config/default_network.json

Lines changed: 15 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -4,82 +4,37 @@
44
"nodes": [
55
{
66
"Alice": {
7-
"app_socket": [
8-
"localhost",
9-
8001
10-
],
11-
"qnodeos_socket": [
12-
"localhost",
13-
8002
14-
],
15-
"vnode_socket": [
16-
"localhost",
17-
8003
18-
]
7+
"app_socket": ["localhost", 8001],
8+
"qnodeos_socket": ["localhost", 8002],
9+
"vnode_socket": ["localhost", 8003]
1910
}
2011
},
2112
{
2213
"Bob": {
23-
"app_socket": [
24-
"localhost",
25-
8010
26-
],
27-
"qnodeos_socket": [
28-
"localhost",
29-
8011
30-
],
31-
"vnode_socket": [
32-
"localhost",
33-
8012
34-
]
14+
"app_socket": ["localhost", 8010],
15+
"qnodeos_socket": ["localhost", 8011],
16+
"vnode_socket": ["localhost", 8012]
3517
}
3618
},
3719
{
3820
"Charlie": {
39-
"app_socket": [
40-
"localhost",
41-
8020
42-
],
43-
"qnodeos_socket": [
44-
"localhost",
45-
8021
46-
],
47-
"vnode_socket": [
48-
"localhost",
49-
8022
50-
]
21+
"app_socket": ["localhost", 8020],
22+
"qnodeos_socket": ["localhost", 8021],
23+
"vnode_socket": ["localhost", 8022]
5124
}
5225
},
5326
{
5427
"David": {
55-
"app_socket": [
56-
"localhost",
57-
8030
58-
],
59-
"qnodeos_socket": [
60-
"localhost",
61-
8031
62-
],
63-
"vnode_socket": [
64-
"localhost",
65-
8032
66-
]
28+
"app_socket": ["localhost", 8030],
29+
"qnodeos_socket": ["localhost", 8031],
30+
"vnode_socket": ["localhost", 8032]
6731
}
6832
},
6933
{
7034
"Eve": {
71-
"app_socket": [
72-
"localhost",
73-
8040
74-
],
75-
"qnodeos_socket": [
76-
"localhost",
77-
8041
78-
],
79-
"vnode_socket": [
80-
"localhost",
81-
8042
82-
]
35+
"app_socket": ["localhost", 8040],
36+
"qnodeos_socket": ["localhost", 8041],
37+
"vnode_socket": ["localhost", 8042]
8338
}
8439
}
8540
],

0 commit comments

Comments
 (0)