Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions hathor/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ def subscribe(self) -> None:
"""
events = [
HathorEvents.NETWORK_NEW_TX_ACCEPTED,
HathorEvents.NETWORK_PEER_CONNECTING,
HathorEvents.NETWORK_PEER_READY,
HathorEvents.NETWORK_PEER_CONNECTED,
HathorEvents.NETWORK_PEER_DISCONNECTED,
Expand All @@ -196,6 +197,7 @@ def handle_publish(self, key: HathorEvents, args: EventArguments) -> None:
self.transactions = self.tx_storage.get_tx_count()
elif key in (
HathorEvents.NETWORK_PEER_READY,
HathorEvents.NETWORK_PEER_CONNECTING,
HathorEvents.NETWORK_PEER_CONNECTED,
HathorEvents.NETWORK_PEER_DISCONNECTED,
HathorEvents.NETWORK_PEER_CONNECTION_FAILED
Expand Down
5 changes: 5 additions & 0 deletions hathor/p2p/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,11 @@ def connect_to(self, description: str, peer: Optional[PeerId] = None, use_ssl: O
deferred.addCallback(self._connect_to_callback, peer, endpoint, connection_string, peer_id)
deferred.addErrback(self.on_connection_failure, peer, endpoint)
self.log.info('connect to ', endpoint=description, peer=str(peer))
self.pubsub.publish(
HathorEvents.NETWORK_PEER_CONNECTING,
peer=peer,
peers_count=self._get_peers_count()
)

def listen(self, description: str, use_ssl: Optional[bool] = None) -> IStreamServerEndpoint:
""" Start to listen to new connection according to the description.
Expand Down
6 changes: 6 additions & 0 deletions hathor/pubsub.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ class HathorEvents(Enum):
Triggered when a new tx/block is accepted in the network
Publishes a tx/block object

NETWORK_PEER_CONNECTING:
Triggered when a peer starts connecting to the network
Publishes the peer id and the peers count

NETWORK_PEER_CONNECTION_FAILURE:
Triggered when a peer connection to the network fails
Publishes the peer id and the peers count
Expand Down Expand Up @@ -91,6 +95,8 @@ class HathorEvents(Enum):
MANAGER_ON_START = 'manager:on_start'
MANAGER_ON_STOP = 'manager:on_stop'

NETWORK_PEER_CONNECTING = 'network:peer_connecting'

NETWORK_PEER_CONNECTION_FAILED = 'network:peer_connection_failed'

NETWORK_PEER_CONNECTED = 'network:peer_connected'
Expand Down