@@ -48,6 +48,11 @@ def str_to_time(as_str: str) -> datetime.datetime:
48
48
return datetime .datetime .strptime (as_str , "%Y-%m-%dT%H:%M:%S" )
49
49
50
50
51
+ def utc_to_local (utc : datetime .datetime ) -> datetime .datetime :
52
+ local_tz = datetime .datetime .now ().astimezone ()
53
+ return utc + local_tz .utcoffset ()
54
+
55
+
51
56
class BasePeerInfo (ABC , HasExtendedDebugLogger ):
52
57
@abstractmethod
53
58
def record_failure (self , remote : Node , failure : BaseP2PError ) -> None :
@@ -116,15 +121,17 @@ def _record_bad_node(self, remote: Node, timeout: int, reason: str) -> None:
116
121
if bad_node :
117
122
new_error_count = bad_node .error_count + 1
118
123
usable_time = now + datetime .timedelta (seconds = timeout * new_error_count )
124
+ local_time = utc_to_local (usable_time )
119
125
self .logger .debug (
120
- '%s will not be retried until %s because %s' , remote , usable_time , reason
126
+ '%s will not be retried until %s because %s' , remote , local_time , reason
121
127
)
122
128
self ._update_bad_node (enode , usable_time , reason , new_error_count )
123
129
return
124
130
125
131
usable_time = now + datetime .timedelta (seconds = timeout )
132
+ local_time = utc_to_local (usable_time )
126
133
self .logger .debug (
127
- '%s will not be retried until %s because %s' , remote , usable_time , reason
134
+ '%s will not be retried until %s because %s' , remote , local_time , reason
128
135
)
129
136
self ._insert_bad_node (enode , usable_time , reason , error_count = 1 )
130
137
@@ -137,9 +144,10 @@ def should_connect_to(self, remote: Node) -> bool:
137
144
138
145
until = str_to_time (bad_node .until )
139
146
if datetime .datetime .utcnow () < until :
147
+ local_time = utc_to_local (until )
140
148
self .logger .debug (
141
149
'skipping %s, it failed because "%s" and is not usable until %s' ,
142
- remote , bad_node .reason , bad_node . until
150
+ remote , bad_node .reason , local_time
143
151
)
144
152
return False
145
153
0 commit comments