Use yield from where possible (#1120)

This commit is contained in:
Jonathan Zernik 2021-08-30 20:23:12 -07:00 committed by GitHub
parent ce47db2e6b
commit dec871876e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 13 deletions

View file

@ -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):

View file

@ -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,
)

View file

@ -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()