Stem out even if we only have 1 peer
This commit is contained in:
parent
cdccde2d9d
commit
ac88e0a1da
@ -81,6 +81,7 @@ async def stem_out(d_phase: 'DandelionPhase'):
|
|||||||
if not len(gossip_peer_set):
|
if not len(gossip_peer_set):
|
||||||
sleep(1)
|
sleep(1)
|
||||||
return
|
return
|
||||||
|
not_enough_edges = False
|
||||||
|
|
||||||
# Spawn threads with deep copied block queue to add to db after time
|
# Spawn threads with deep copied block queue to add to db after time
|
||||||
# for black hole attack
|
# for black hole attack
|
||||||
@ -96,15 +97,17 @@ async def stem_out(d_phase: 'DandelionPhase'):
|
|||||||
# Using orderedset for the tried edges to ensure random pairing with queue
|
# Using orderedset for the tried edges to ensure random pairing with queue
|
||||||
tried_edges: "OrderedSet[Peer]" = OrderedSet()
|
tried_edges: "OrderedSet[Peer]" = OrderedSet()
|
||||||
|
|
||||||
while len(peer_sockets) < OUTBOUND_DANDELION_EDGES:
|
while len(peer_sockets) < OUTBOUND_DANDELION_EDGES or not_enough_edges:
|
||||||
try:
|
try:
|
||||||
# Get a socket for stem out (makes sure they accept)
|
# Get a socket for stem out (makes sure they accept)
|
||||||
peer_sockets.append(await _setup_edge(gossip_peer_set, tried_edges))
|
peer_sockets.append(await _setup_edge(gossip_peer_set, tried_edges))
|
||||||
except NotEnoughEdges:
|
except NotEnoughEdges:
|
||||||
# No possible edges at this point (edges < OUTBOUND_DANDELION_EDGE)
|
# No possible edges at this point (edges < OUTBOUND_DANDELION_EDGE)
|
||||||
logger.warn("Not able to build enough tunnels for stemout.",
|
logger.warn(
|
||||||
|
"Making too few edges for stemout " +
|
||||||
|
"this is bad for anonymity if frequent."
|
||||||
terminal=True)
|
terminal=True)
|
||||||
break
|
not_enough_edges = True
|
||||||
else:
|
else:
|
||||||
# Ran out of time for stem phase
|
# Ran out of time for stem phase
|
||||||
if not d_phase.is_stem_phase() or d_phase.remaining_time() < 5:
|
if not d_phase.is_stem_phase() or d_phase.remaining_time() < 5:
|
||||||
|
Loading…
Reference in New Issue
Block a user