11import itertools
22from typing import (
33 cast ,
4- Any ,
5- Dict ,
64 Iterable ,
75 Set ,
86 Type ,
3331from eth .beacon .types .blocks import BaseBeaconBlock
3432
3533from trinity .protocol .common .servers import BaseRequestServer
36- from trinity .protocol .bcc import commands
34+ from trinity .protocol .bcc .commands import (
35+ GetBeaconBlocks ,
36+ GetBeaconBlocksMessage ,
37+ )
3738from trinity .protocol .bcc .peer import (
3839 BCCPeer ,
3940 BCCPeerPool ,
4243
4344class BCCRequestServer (BaseRequestServer ):
4445 subscription_msg_types : Set [Type [Command ]] = {
45- commands . GetBeaconBlocks ,
46+ GetBeaconBlocks ,
4647 }
4748
4849 def __init__ (self ,
@@ -56,16 +57,16 @@ async def _handle_msg(self, base_peer: BasePeer, cmd: Command,
5657 msg : protocol ._DecodedMsgType ) -> None :
5758 peer = cast (BCCPeer , base_peer )
5859
59- if isinstance (cmd , commands . GetBeaconBlocks ):
60- await self ._handle_get_beacon_blocks (peer , cast (Dict [ str , Any ] , msg ))
60+ if isinstance (cmd , GetBeaconBlocks ):
61+ await self ._handle_get_beacon_blocks (peer , cast (GetBeaconBlocksMessage , msg ))
6162 else :
6263 raise Exception ("Invariant: Only subscribed to GetBeaconBlocks" )
6364
64- async def _handle_get_beacon_blocks (self , peer : BCCPeer , msg : Dict [ str , Any ] ) -> None :
65+ async def _handle_get_beacon_blocks (self , peer : BCCPeer , msg : GetBeaconBlocksMessage ) -> None :
6566 if not peer .is_operational :
6667 return
6768
68- max_blocks = cast ( int , msg ["max_blocks" ])
69+ max_blocks = msg ["max_blocks" ]
6970 block_slot_or_hash = msg ["block_slot_or_hash" ]
7071
7172 try :
0 commit comments