diff --git a/chia/_tests/core/full_node/test_address_manager.py b/chia/_tests/core/full_node/test_address_manager.py index 7163f98c7764..ef791ddd7469 100644 --- a/chia/_tests/core/full_node/test_address_manager.py +++ b/chia/_tests/core/full_node/test_address_manager.py @@ -560,7 +560,7 @@ async def check_retrieved_peers(self, wanted_peers: list[ExtendedPeerInfo], addr # use tmp_path pytest fixture to create a temporary directory async def test_serialization(self, tmp_path: Path): addrman = AddressManagerTest() - now = int(math.floor(time.time())) + now = math.floor(time.time()) t_peer1 = TimestampedPeerInfo("250.7.1.1", uint16(8333), uint64(now - 10000)) t_peer2 = TimestampedPeerInfo("1050:0000:0000:0000:0005:0600:300c:326b", uint16(9999), uint64(now - 20000)) t_peer3 = TimestampedPeerInfo("250.7.3.3", uint16(9999), uint64(now - 30000)) @@ -587,7 +587,7 @@ async def test_serialization(self, tmp_path: Path): @pytest.mark.anyio async def test_bad_ip_encoding(self, tmp_path: Path): addrman = AddressManagerTest() - now = int(math.floor(time.time())) + now = math.floor(time.time()) t_peer1 = TimestampedPeerInfo("250.7.1.1", uint16(8333), uint64(now - 10000)) t_peer2 = TimestampedPeerInfo("1050:0000:0000:0000:0005:0600:300c:326b", uint16(9999), uint64(now - 20000)) t_peer3 = TimestampedPeerInfo("250.7.3.3", uint16(9999), uint64(now - 30000)) @@ -725,7 +725,7 @@ async def old_serialize(address_manager: AddressManager, peers_file_path: Path) # create a file with the old serialization, then migrate to new serialization addrman = AddressManagerTest() - now = int(math.floor(time.time())) + now = math.floor(time.time()) t_peer1 = TimestampedPeerInfo("250.7.1.1", uint16(8333), uint64(now - 10000)) t_peer2 = TimestampedPeerInfo("1050:0000:0000:0000:0005:0600:300c:326b", uint16(9999), uint64(now - 20000)) t_peer3 = TimestampedPeerInfo("250.7.3.3", uint16(9999), uint64(now - 30000)) diff --git a/chia/plotting/check_plots.py b/chia/plotting/check_plots.py index 0fe7c2567fa5..f4d2a7ab61b0 100644 --- a/chia/plotting/check_plots.py +++ b/chia/plotting/check_plots.py @@ -170,9 +170,9 @@ def process_plot(plot_path: Path, plot_info: PlotInfo, num_start: int, num_end: challenge = std_hash(i.to_bytes(32, "big")) # Some plot errors cause get_qualities_for_challenge to throw a RuntimeError try: - quality_start_time = int(round(time() * 1000)) + quality_start_time = round(time() * 1000) for index, quality_str in enumerate(pr.get_qualities_for_challenge(challenge)): - quality_spent_time = int(round(time() * 1000)) - quality_start_time + quality_spent_time = round(time() * 1000) - quality_start_time if quality_spent_time > 8000: log.warning( f"\tLooking up qualities took: {quality_spent_time} ms. This should be below 8 seconds " @@ -183,9 +183,9 @@ def process_plot(plot_path: Path, plot_info: PlotInfo, num_start: int, num_end: # Other plot errors cause get_full_proof or validate_proof to throw an AssertionError try: - proof_start_time = int(round(time() * 1000)) + proof_start_time = round(time() * 1000) proof = pr.get_full_proof(challenge, index, parallel_read) - proof_spent_time = int(round(time() * 1000)) - proof_start_time + proof_spent_time = round(time() * 1000) - proof_start_time if proof_spent_time > 15000: log.warning( f"\tFinding proof took: {proof_spent_time} ms. This should be below 15 seconds " @@ -207,7 +207,7 @@ def process_plot(plot_path: Path, plot_info: PlotInfo, num_start: int, num_end: f"{type(e)}: {e} error in proving/verifying for plot {plot_path}. Filepath: {plot_path}" ) caught_exception = True - quality_start_time = int(round(time() * 1000)) + quality_start_time = round(time() * 1000) except KeyboardInterrupt: log.warning("Interrupted, closing") return diff --git a/chia/server/address_manager.py b/chia/server/address_manager.py index 3ebf0250a7cf..3a3130f03f90 100644 --- a/chia/server/address_manager.py +++ b/chia/server/address_manager.py @@ -177,7 +177,7 @@ def get_bucket_position(self, key: int, is_new: bool, nBucket: int) -> int: def is_terrible(self, now: Optional[int] = None) -> bool: if now is None: - now = int(math.floor(time.time())) + now = math.floor(time.time()) # never remove things tried in the last minute if self.last_try > 0 and self.last_try >= now - 60: return False @@ -202,7 +202,7 @@ def is_terrible(self, now: Optional[int] = None) -> bool: def get_selection_chance(self, now: Optional[int] = None) -> float: if now is None: - now = int(math.floor(time.time())) + now = math.floor(time.time()) chance = 1.0 since_last_try = max(now - self.last_try, 0) # deprioritize very recent attempts away @@ -734,7 +734,7 @@ def get_peers_(self) -> list[TimestampedPeerInfo]: return addr def cleanup(self, max_timestamp_difference: int, max_consecutive_failures: int) -> None: - now = int(math.floor(time.time())) + now = math.floor(time.time()) for bucket in range(NEW_BUCKET_COUNT): for pos in range(BUCKET_SIZE): if self.new_matrix[bucket][pos] != -1: diff --git a/ruff.toml b/ruff.toml index 6bb3e82f6c2a..dabc2822f406 100644 --- a/ruff.toml +++ b/ruff.toml @@ -90,7 +90,6 @@ ignore = [ "RUF056", # falsy-dict-get-fallback # Should probably fix this "RUF029", # unused-async - "RUF046", # unnecessary-cast-to-int "RUF052", # used-dummy-variable # Security linter