mirror of
https://github.com/logos-blockchain/logos-blockchain-specs.git
synced 2026-01-07 23:53:11 +00:00
use start_delayed helper
This commit is contained in:
parent
546e90b2e9
commit
de554e95d1
@ -73,9 +73,6 @@ class Node:
|
||||
and forwards it to the next mix or the entire network if necessary.
|
||||
@param msg: the message to be processed
|
||||
"""
|
||||
# simulating network latency
|
||||
yield self.env.timeout(random.uniform(0, self.config.max_network_latency))
|
||||
|
||||
if isinstance(msg, SphinxPacket):
|
||||
msg, incentive_tx = msg.unwrap(self.private_key)
|
||||
if self.is_my_incentive_tx(incentive_tx):
|
||||
|
||||
@ -3,6 +3,7 @@ import random
|
||||
from collections import defaultdict
|
||||
|
||||
import simpy
|
||||
from simpy.util import start_delayed
|
||||
|
||||
from config import Config
|
||||
from sphinx import SphinxPacket
|
||||
@ -34,7 +35,8 @@ class P2p:
|
||||
|
||||
# TODO: gossipsub or something similar
|
||||
for node in self.nodes:
|
||||
self.env.process(node.receive_message(msg))
|
||||
network_delay = random.uniform(0, self.config.max_network_latency)
|
||||
start_delayed(self.env, node.receive_message(msg), delay=network_delay)
|
||||
|
||||
def get_nodes(self, n: int):
|
||||
return random.sample(self.nodes, n)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user