mirror of
https://github.com/Chia-Network/chia-blockchain.git
synced 2024-09-11 10:56:14 +03:00
farmer: Improve logging in plot_sync.{receiver|delta}
(#11474)
* Add the `node_id` to the logs in `Receiver` * Log all processed messages * Log reset calls * Improve `reciever.Sync` and `delta.Delta` logging
This commit is contained in:
parent
b964c200d7
commit
3e3dafb0ef
@ -48,8 +48,8 @@ class Delta:
|
||||
|
||||
def __str__(self) -> str:
|
||||
return (
|
||||
f"valid {self.valid}, invalid {self.invalid}, keys missing: {self.keys_missing}, "
|
||||
f"duplicates: {self.duplicates}"
|
||||
f"[valid {self.valid}, invalid {self.invalid}, keys missing: {self.keys_missing}, "
|
||||
f"duplicates: {self.duplicates}]"
|
||||
)
|
||||
|
||||
def clear(self) -> None:
|
||||
|
@ -53,6 +53,17 @@ class Sync:
|
||||
def bump_plots_processed(self) -> None:
|
||||
self.plots_processed = uint32(self.plots_processed + 1)
|
||||
|
||||
def __str__(self) -> str:
|
||||
return (
|
||||
f"[state {self.state}, "
|
||||
f"sync_id {self.sync_id}, "
|
||||
f"next_message_id {self.next_message_id}, "
|
||||
f"plots_processed {self.plots_processed}, "
|
||||
f"plots_total {self.plots_total}, "
|
||||
f"delta {self.delta}, "
|
||||
f"time_done {self.time_done}]"
|
||||
)
|
||||
|
||||
|
||||
class ReceiverUpdateCallback(Protocol):
|
||||
def __call__(self, peer_id: bytes32, delta: Optional[Delta]) -> Awaitable[None]:
|
||||
@ -89,9 +100,10 @@ class Receiver:
|
||||
try:
|
||||
await self._update_callback(self._connection.peer_node_id, update)
|
||||
except Exception as e:
|
||||
log.error(f"_update_callback raised: {e}")
|
||||
log.error(f"_update_callback: node_id {self.connection().peer_node_id}, raised {e}")
|
||||
|
||||
def reset(self) -> None:
|
||||
log.error(f"reset: node_id {self.connection().peer_node_id}, current_sync: {self._current_sync}")
|
||||
self._current_sync = Sync()
|
||||
self._last_sync = Sync()
|
||||
self._plots.clear()
|
||||
@ -130,6 +142,10 @@ class Receiver:
|
||||
async def _process(
|
||||
self, method: Callable[[_T_Streamable], Any], message_type: ProtocolMessageTypes, message: Any
|
||||
) -> None:
|
||||
log.debug(
|
||||
f"_process: node_id {self.connection().peer_node_id}, message_type: {message_type}, message: {message}"
|
||||
)
|
||||
|
||||
async def send_response(plot_sync_error: Optional[PlotSyncError] = None) -> None:
|
||||
if self._connection is not None:
|
||||
await self._connection.send_message(
|
||||
@ -143,13 +159,13 @@ class Receiver:
|
||||
await method(message)
|
||||
await send_response()
|
||||
except InvalidIdentifierError as e:
|
||||
log.warning(f"_process: InvalidIdentifierError {e}")
|
||||
log.warning(f"_process: node_id {self.connection().peer_node_id}, InvalidIdentifierError {e}")
|
||||
await send_response(PlotSyncError(int16(e.error_code), f"{e}", e.expected_identifier))
|
||||
except PlotSyncException as e:
|
||||
log.warning(f"_process: Error {e}")
|
||||
log.warning(f"_process: node_id {self.connection().peer_node_id}, Error {e}")
|
||||
await send_response(PlotSyncError(int16(e.error_code), f"{e}", None))
|
||||
except Exception as e:
|
||||
log.warning(f"_process: Exception {e}")
|
||||
log.warning(f"_process: node_id {self.connection().peer_node_id}, Exception {e}")
|
||||
await send_response(PlotSyncError(int16(ErrorCodes.unknown), f"{e}", None))
|
||||
|
||||
def _validate_identifier(self, identifier: PlotSyncIdentifier, start: bool = False) -> None:
|
||||
|
Loading…
Reference in New Issue
Block a user