Skip to content

Commit

Permalink
Bugfix for the task queue buildup (#8315)
Browse files Browse the repository at this point in the history
* fix bug

* remove except
  • Loading branch information
Yostra authored Sep 7, 2021
1 parent 0096f75 commit c353048
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion chia/full_node/full_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def __init__(
self.signage_point_times = [time.time() for _ in range(self.constants.NUM_SPS_SUB_SLOT)]
self.full_node_store = FullNodeStore(self.constants)
self.uncompact_task = None

self.compact_vdf_requests: Set[bytes32] = set()
self.log = logging.getLogger(name if name else __name__)

self._ui_tasks = set()
Expand Down
21 changes: 19 additions & 2 deletions chia/full_node/full_node_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1273,13 +1273,30 @@ async def respond_compact_proof_of_time(self, request: timelord_protocol.Respond
@execute_task
@peer_required
@api_request
async def new_compact_vdf(self, request: full_node_protocol.NewCompactVDF, peer: ws.WSChiaConnection):
@bytes_required
async def new_compact_vdf(
self, request: full_node_protocol.NewCompactVDF, peer: ws.WSChiaConnection, request_bytes: bytes = b""
):
if self.full_node.sync_store.get_sync_mode():
return None

if len(self.full_node.compact_vdf_sem._waiters) > 20:
self.log.debug(f"Ignoring NewCompactVDF: {request}, _waiters")
return

name = std_hash(request_bytes)
if name in self.full_node.compact_vdf_requests:
self.log.debug(f"Ignoring NewCompactVDF: {request}, already requested")
return
self.full_node.compact_vdf_requests.add(name)

# this semaphore will only allow a limited number of tasks call
# new_compact_vdf() at a time, since it can be expensive
async with self.full_node.compact_vdf_sem:
await self.full_node.new_compact_vdf(request, peer)
try:
await self.full_node.new_compact_vdf(request, peer)
finally:
self.full_node.compact_vdf_requests.remove(name)

@peer_required
@api_request
Expand Down

0 comments on commit c353048

Please sign in to comment.