File tree Expand file tree Collapse file tree
src/lean_spec/subspecs/networking Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1313 BlocksByRootResponse ,
1414 Status ,
1515)
16+ from .topics import GossipTopic
1617from .types import DomainType , ProtocolId
1718
1819__all__ = [
2526 "BlocksByRootRequest" ,
2627 "BlocksByRootResponse" ,
2728 "Status" ,
29+ "GossipTopic" ,
2830 "DomainType" ,
2931 "ProtocolId" ,
3032]
Original file line number Diff line number Diff line change 1+ """Gossipsub topics"""
2+
3+ from enum import Enum
4+ from typing import Any , Type
5+
6+ from lean_spec .subspecs .containers .block .block import SignedBlock
7+ from lean_spec .subspecs .containers .vote import SignedVote
8+
9+
10+ class GossipTopic (Enum ):
11+ """
12+ Enumerates gossip topics, bundling a topic's name with its payload type.
13+
14+ Attributes:
15+ value (str): The network name of the topic (e.g., "block").
16+ payload_type (Type): The class representing the data structure
17+ of the topic's message (e.g., `SignedBlock`).
18+ """
19+
20+ def __init__ (self , value : str , payload_type : Type [Any ]):
21+ """
22+ Initializes the GossipTopic.
23+
24+ Args:
25+ value: The topic in string.
26+ payload_type: The associated gossip.
27+ """
28+ self ._value_ = value
29+ self .payload_type = payload_type
30+
31+ BLOCK = ("block" , SignedBlock )
32+ """
33+ Topic for gossiping new blocks.
34+
35+ - `value`: "block"
36+ - `payload_type`: `SignedBlock`
37+ """
38+
39+ VOTE = ("vote" , SignedVote )
40+ """
41+ Topic for gossiping new votes (attestations).
42+
43+ - `value`: "vote"
44+ - `payload_type`: `SignedVote`
45+ """
You can’t perform that action at this time.
0 commit comments