@@ -567,6 +567,10 @@ def subscription_msg_types(self) -> Set[Type[protocol.Command]]:
567
567
568
568
The base command class `p2p.protocol.Command` can be used to enable
569
569
**all** command types.
570
+
571
+ .. note: This API only applies to sub-protocol commands. Base protocol
572
+ commands are handled exclusively at the peer level and cannot be
573
+ consumed with this API.
570
574
"""
571
575
pass
572
576
@@ -610,25 +614,22 @@ def add_msg(self, msg: 'PEER_MSG_TYPE') -> bool:
610
614
peer , cmd , _ = msg
611
615
612
616
if not self .is_subscription_command (type (cmd )):
613
- if hasattr (self , 'logger' ):
614
- self .logger .trace ( # type: ignore
615
- "Discarding %s msg from %s; not subscribed to msg type; "
616
- "subscriptions: %s" ,
617
- cmd , peer , self .subscription_msg_types ,
618
- )
617
+ self .logger .trace ( # type: ignore
618
+ "Discarding %s msg from %s; not subscribed to msg type; "
619
+ "subscriptions: %s" ,
620
+ cmd , peer , self .subscription_msg_types ,
621
+ )
619
622
return False
620
623
621
624
try :
622
- if hasattr (self , 'logger' ):
623
- self .logger .trace ( # type: ignore
624
- "Adding %s msg from %s to queue; queue_size=%d" , cmd , peer , self .queue_size )
625
+ self .logger .trace ( # type: ignore
626
+ "Adding %s msg from %s to queue; queue_size=%d" , cmd , peer , self .queue_size )
625
627
self .msg_queue .put_nowait (msg )
626
628
return True
627
629
except asyncio .queues .QueueFull :
628
- if hasattr (self , 'logger' ):
629
- self .logger .warn ( # type: ignore
630
- "%s msg queue is full; discarding %s msg from %s" ,
631
- self .__class__ .__name__ , cmd , peer )
630
+ self .logger .warn ( # type: ignore
631
+ "%s msg queue is full; discarding %s msg from %s" ,
632
+ self .__class__ .__name__ , cmd , peer )
632
633
return False
633
634
634
635
@contextlib .contextmanager
0 commit comments