@@ -289,7 +289,7 @@ def process(response: List[kademlia.Node]) -> None:
289
289
return tuple (n for n in neighbours if n != self .this_node )
290
290
291
291
def _mkpingid (self , token : Hash32 , node : kademlia .Node ) -> Hash32 :
292
- return token + node .pubkey .to_bytes ()
292
+ return Hash32 ( token + node .pubkey .to_bytes () )
293
293
294
294
def _send_find_node (self , node : kademlia .Node , target_node_id : int ) -> None :
295
295
if self .use_v5 :
@@ -492,7 +492,7 @@ def send_ping_v4(self, node: kademlia.Node) -> Hash32:
492
492
message = _pack_v4 (CMD_PING .id , payload , self .privkey )
493
493
self .send (node , message )
494
494
# Return the msg hash, which is used as a token to identify pongs.
495
- token = message [:MAC_SIZE ]
495
+ token = Hash32 ( message [:MAC_SIZE ])
496
496
self .logger .trace ('>>> ping (v4) %s (token == %s)' , node , encode_hex (token ))
497
497
# XXX: This hack is needed because there are lots of parity 1.10 nodes out there that send
498
498
# the wrong token on pong msgs (https://github.com/paritytech/parity/issues/8038). We
@@ -680,7 +680,7 @@ def recv_topic_register(self, node: kademlia.Node, payload: Tuple[Any, ...],
680
680
topic_idx = big_endian_to_int (idx )
681
681
self .logger .trace (
682
682
'<<< topic_register from %s, topics: %s, idx: %d' , node , topics , topic_idx )
683
- _ , _ , pong_payload , _ = _unpack_v5 (raw_pong )
683
+ key , cmd_id , pong_payload , _ = _unpack_v5 (raw_pong )
684
684
_ , _ , _ , _ , ticket_serial , _ = pong_payload
685
685
self .topic_table .use_ticket (node , big_endian_to_int (ticket_serial ), topics [topic_idx ])
686
686
@@ -1132,7 +1132,7 @@ def _unpack_v4(message: bytes) -> Tuple[datatypes.PublicKey, int, Tuple[Any, ...
1132
1132
1133
1133
Returns the public key used to sign the message, the cmd ID, payload and hash.
1134
1134
"""
1135
- message_hash = message [:MAC_SIZE ]
1135
+ message_hash = Hash32 ( message [:MAC_SIZE ])
1136
1136
if message_hash != keccak (message [MAC_SIZE :]):
1137
1137
raise WrongMAC ("Wrong msg mac" )
1138
1138
signature = keys .Signature (message [MAC_SIZE :HEAD_SIZE ])
0 commit comments