Fix var access before assignment

This commit is contained in:
NIC619 2019-12-03 22:14:45 +08:00
parent ea6cd30a16
commit bb15c817b1
No known key found for this signature in database
GPG Key ID: 570C35F5C2D51B17
2 changed files with 4 additions and 4 deletions

View File

@ -314,9 +314,11 @@ class GossipSub(IPubsubRouter):
peers_to_prune: Dict[ID, List[str]],
peers_to_gossip: Dict[ID, Dict[str, List[str]]],
) -> None:
graft_msgs: List[rpc_pb2.ControlGraft] = []
prune_msgs: List[rpc_pb2.ControlPrune] = []
ihave_msgs: List[rpc_pb2.ControlIHave] = []
# Starting with GRAFT messages
for peer, topics in peers_to_graft.items():
graft_msgs: List[rpc_pb2.ControlGraft] = []
for topic in topics:
graft_msg: rpc_pb2.ControlGraft = rpc_pb2.ControlGraft()
graft_msg.topicID = topic
@ -324,7 +326,6 @@ class GossipSub(IPubsubRouter):
# If there are also PRUNE messages to send to this peer
if peer in peers_to_prune:
prune_msgs: List[rpc_pb2.ControlPrune] = []
for topic in peers_to_prune[peer]:
prune_msg: rpc_pb2.ControlPrune = rpc_pb2.ControlPrune()
prune_msg.topicID = topic
@ -333,7 +334,6 @@ class GossipSub(IPubsubRouter):
# If there are also IHAVE messages to send to this peer
if peer in peers_to_gossip:
ihave_msgs: List[rpc_pb2.ControlIHave] = []
for topic in peers_to_gossip[peer]:
ihave_msg: rpc_pb2.ControlIHave = rpc_pb2.ControlIHave()
ihave_msg.messageIDs.extend(peers_to_gossip[peer][topic])

View File

@ -197,7 +197,7 @@ async def test_dense(num_hosts, pubsubs_gsub, hosts):
# publish from the randomly chosen host
await pubsubs_gsub[origin_idx].publish("foobar", msg_content)
await asyncio.sleep(2)
await asyncio.sleep(0.5)
# Assert that all blocking queues receive the message
for queue in queues:
msg = await queue.get()