Skip to content

Commit

Permalink
Update protocol and api for RequestPuzzleState
Browse files Browse the repository at this point in the history
  • Loading branch information
Rigidity committed Jan 18, 2024
1 parent b9fa75f commit 9c51ce5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
14 changes: 6 additions & 8 deletions chia/full_node/full_node_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1729,26 +1729,24 @@ async def request_puzzle_state(
count = 15000
puzzle_hashes = request.puzzle_hashes[:count]

(coin_states, next_height, is_finished) = await self.full_node.coin_store.batch_coin_states_by_puzzle_hashes(
(coin_states, next_height) = await self.full_node.coin_store.batch_coin_states_by_puzzle_hashes(
puzzle_hashes,
min_height=request.min_height,
include_spent=request.filters.include_spent,
include_unspent=request.filters.include_unspent,
include_hinted=request.filters.include_hinted,
)

next_header_hash = self.full_node.blockchain.height_to_hash(next_height)
assert next_header_hash is not None

if is_finished:
if next_height is None:
next_header_hash = None
peer_id = peer.peer_node_id
subs = self.full_node.subscriptions
max_subscriptions = self.max_subscriptions(peer)
subs.add_puzzle_subscriptions(peer_id, puzzle_hashes, max_subscriptions)
else:
next_header_hash = self.full_node.blockchain.height_to_hash(next_height)

response = wallet_protocol.RespondPuzzleState(
puzzle_hashes, next_height, next_header_hash, is_finished, coin_states
)
response = wallet_protocol.RespondPuzzleState(puzzle_hashes, next_height, next_header_hash, coin_states)
msg = make_msg(ProtocolMessageTypes.respond_puzzle_state, response)
return msg

Expand Down
5 changes: 2 additions & 3 deletions chia/protocols/wallet_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,9 +365,8 @@ class RequestPuzzleState(Streamable):
@dataclass(frozen=True)
class RespondPuzzleState(Streamable):
puzzle_hashes: List[bytes32]
next_height: uint32
next_header_hash: bytes32
is_finished: bool
next_height: Optional[uint32]
next_header_hash: Optional[bytes32]
coin_states: List[CoinState]


Expand Down

0 comments on commit 9c51ce5

Please sign in to comment.