Corrected type hinting for block queues and peer sets

This commit is contained in:
Kevin F 2022-03-20 12:54:57 -05:00
parent 9ef6f46a5c
commit be1dde95a6
5 changed files with 11 additions and 11 deletions

View File

@ -2,11 +2,11 @@ import threading
from time import sleep
from typing import TYPE_CHECKING, Set, Tuple
from os import urandom
import queue
if TYPE_CHECKING:
from ordered_set import OrderedSet
from onionrblocks import Block
from queue import Queue
from .peer import Peer
@ -41,8 +41,8 @@ In stem phase, server disables diffusion
def start_gossip_threads(
peer_set: OrderedSet['Peer'],
block_queues: Tuple[queue.Queue['Block']]):
peer_set: "OrderedSet[Peer]",
block_queues: Tuple["Queue[Block]"]):
# Peer set is largely handled by the transport plugins
# There is a unified set so gossip logic is not repeated
seed = urandom(32)

View File

@ -50,8 +50,8 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
def gossip_client(
peer_set: OrderedSet['Peer'],
block_queues: Tuple[Queue['Block'], Queue['Block']],
peer_set: "OrderedSet[Peer]",
block_queues: Tuple["Queue[Block]", "Queue[Block]"],
dandelion_seed: bytes):
"""
Gossip client does the following:

View File

@ -10,12 +10,12 @@ if TYPE_CHECKING:
def store_blocks(
block_queues: Tuple[Queue['Block'], Queue['Block']],
block_queues: Tuple["Queue[Block]", "Queue[Block]"],
dandelion_phase: 'DandelionPhase'):
new_queue: Queue['Block'] = Queue()
new_queue: "Queue[Block]" = Queue()
def _watch_queue(block_queue: Queue['Block']):
def _watch_queue(block_queue: "Queue[Block]"):
# Copy all incoming blocks into 1 queue which gets processed to db
while not dandelion_phase.is_stem_phase() \
and dandelion_phase.remaining_time() > 1:

View File

@ -39,8 +39,8 @@ inbound_dandelion_edge_count = [0]
def gossip_server(
peer_set: OrderedSet['Peer'],
block_queues: Tuple[Queue['Block'], Queue['Block']],
peer_set: "OrderedSet[Peer]",
block_queues: Tuple["Queue[Block]", "Queue[Block]"],
dandelion_seed: bytes):
async def peer_connected(

View File

@ -20,7 +20,7 @@ if TYPE_CHECKING:
async def accept_stem_blocks(
block_queues: Tuple[Queue['Block'], Queue['Block']],
block_queues: Tuple["Queue[Block]", "Queue[Block]"],
reader: 'StreamReader',
writer: 'StreamWriter',
inbound_edge_count: List[int]):