mirror of
https://github.com/yzernik/squeaknode.git
synced 2026-08-15 12:50:47 +02:00
Use yield from where possible (#1120)
This commit is contained in:
parent
ce47db2e6b
commit
dec871876e
3 changed files with 8 additions and 13 deletions
|
|
@ -118,8 +118,7 @@ class ConnectionManager(object):
|
|||
peer.stop()
|
||||
|
||||
def yield_peers_changed(self, stopped: threading.Event):
|
||||
for item in self.peer_changed_listener.yield_items(stopped):
|
||||
yield item
|
||||
yield from self.peer_changed_listener.yield_items(stopped)
|
||||
|
||||
def yield_single_peer_changed(self, peer_address: PeerAddress, stopped: threading.Event):
|
||||
for peer in self.single_peer_changed_listener.yield_items(stopped):
|
||||
|
|
|
|||
|
|
@ -137,12 +137,10 @@ class NetworkManager(object):
|
|||
)
|
||||
|
||||
def subscribe_connected_peers(self, stopped):
|
||||
for result in self.connection_manager.yield_peers_changed(stopped):
|
||||
yield result
|
||||
yield from self.connection_manager.yield_peers_changed(stopped)
|
||||
|
||||
def subscribe_connected_peer(self, peer_address: PeerAddress, stopped):
|
||||
for result in self.connection_manager.yield_single_peer_changed(
|
||||
peer_address,
|
||||
stopped,
|
||||
):
|
||||
yield result
|
||||
yield from self.connection_manager.yield_single_peer_changed(
|
||||
peer_address,
|
||||
stopped,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -407,8 +407,7 @@ class SqueakController:
|
|||
initial_index,
|
||||
stopped,
|
||||
).open_subscription() as client:
|
||||
for payment in client.get_received_payments():
|
||||
yield payment
|
||||
yield from client.get_received_payments()
|
||||
|
||||
def get_block_range(self) -> BlockRange:
|
||||
max_block = self.squeak_core.get_best_block_height()
|
||||
|
|
@ -674,8 +673,7 @@ class SqueakController:
|
|||
return self.network_manager.subscribe_connected_peer(peer_address, stopped)
|
||||
|
||||
def subscribe_new_squeaks(self, stopped: threading.Event):
|
||||
for item in self.new_squeak_listener.yield_items(stopped):
|
||||
yield item
|
||||
yield from self.new_squeak_listener.yield_items(stopped)
|
||||
|
||||
def update_subscriptions(self):
|
||||
locator = self.get_interested_locator()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue