Clean up code
This commit is contained in:
parent
8acec4d2ed
commit
cd43db0861
|
@ -58,11 +58,8 @@ def get_num_receivers_in_topology(topology):
|
|||
|
||||
async def main():
|
||||
# Create sender
|
||||
print("Sender created")
|
||||
sender = await SenderNode.create(ACK_PROTOCOL)
|
||||
|
||||
# Create receivers
|
||||
print("Receivers created")
|
||||
print("Sender created")
|
||||
|
||||
# Define connection topology
|
||||
topology_dict = json.loads(open(sys.argv[1]).read())
|
||||
|
@ -76,14 +73,16 @@ async def main():
|
|||
|
||||
topics = topic_map.keys()
|
||||
|
||||
# Create receivers
|
||||
receivers = await create_receivers(num_receivers, topic_map)
|
||||
print("Receivers created")
|
||||
|
||||
# Create network topology
|
||||
await create_topology(topology, sender, receivers)
|
||||
print("Topology created")
|
||||
|
||||
# Perform throughput test
|
||||
# 1) Start receivers
|
||||
# First, start receivers
|
||||
sender_info = info_from_p2p_addr(sender.libp2p_node.get_addrs()[0])
|
||||
for receiver in receivers:
|
||||
print("Starting receiving")
|
||||
|
@ -92,13 +91,14 @@ async def main():
|
|||
# Allow time for start receiving to be completed
|
||||
await asyncio.sleep(0.5)
|
||||
|
||||
# 2) Start sending messages and perform throughput test
|
||||
# Start sending messages and perform throughput test
|
||||
# Determine number of receivers in each topic
|
||||
num_receivers_in_each_topic = {}
|
||||
for topic in topic_map:
|
||||
num_receivers_in_each_topic[topic] = len(topic_map[topic])
|
||||
print("Performing test")
|
||||
await sender.perform_test(num_receivers_in_each_topic, topics, 10)
|
||||
|
||||
print("All testing completed")
|
||||
await cleanup()
|
||||
|
||||
|
|
|
@ -47,8 +47,8 @@
|
|||
|
||||
|
||||
// parsing and collecting nodes and edges from the python
|
||||
nodes = new vis.DataSet([{"color": "#70ec84", "id": 0, "label": 0, "shape": "dot"}, {"color": "#70ec84", "id": 1, "label": 1, "shape": "dot"}, {"color": "#70ec84", "id": 2, "label": 2, "shape": "dot"}, {"color": "#70ec84", "id": 3, "label": 3, "shape": "dot"}, {"id": "sender", "label": "sender", "shape": "dot"}]);
|
||||
edges = new vis.DataSet([{"from": "sender", "to": 0}, {"from": 0, "to": 1}, {"from": 1, "to": 2}, {"from": 2, "to": 3}]);
|
||||
nodes = new vis.DataSet([{"color": "#70ec84", "id": 0, "label": 0, "shape": "dot"}, {"color": "#70ec84", "id": 1, "label": 1, "shape": "dot"}, {"color": "#ffa07a", "id": 2, "label": 2, "shape": "dot"}, {"color": "#ffa07a", "id": 3, "label": 3, "shape": "dot"}, {"color": "#005582", "id": 4, "label": 4, "shape": "dot"}, {"color": "#005582", "id": 5, "label": 5, "shape": "dot"}, {"id": "sender", "label": "sender", "shape": "dot"}]);
|
||||
edges = new vis.DataSet([{"from": "sender", "to": 0}, {"from": "sender", "to": 2}, {"from": "sender", "to": 4}, {"from": 0, "to": 1}, {"from": 2, "to": 3}, {"from": 4, "to": 5}]);
|
||||
|
||||
// adding nodes and edges to the graph
|
||||
data = {nodes: nodes, edges: edges};
|
||||
|
|
|
@ -23,7 +23,7 @@ class ReceiverNode():
|
|||
@classmethod
|
||||
async def create(cls, ack_protocol, topic):
|
||||
"""
|
||||
Create a new DummyAccountNode and attach a libp2p node, a floodsub, and a pubsub
|
||||
Create a new ReceiverNode and attach a libp2p node, a floodsub, and a pubsub
|
||||
instance to this new node
|
||||
|
||||
We use create as this serves as a factory function and allows us
|
||||
|
|
|
@ -14,9 +14,7 @@ TOPIC = "eth"
|
|||
|
||||
class SenderNode():
|
||||
"""
|
||||
Node which has an internal balance mapping, meant to serve as
|
||||
a dummy crypto blockchain. There is no actual blockchain, just a simple
|
||||
map indicating how much crypto each user in the mappings holds
|
||||
SenderNode which pings ReceiverNodes continuously to perform benchmarking
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
|
|
Loading…
Reference in New Issue
Block a user