Skip to content
Open
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
25 changes: 25 additions & 0 deletions agi/network/monitoring/P2PGossipMonitor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import time

class P2PGossipMonitor:
"""
Monitor for the P2P gossip protocol in the AGI system.
Tracks experiment distribution and agent synchronization.
"""
def __init__(self, node_id):
self.node_id = node_id
self.stats = {"messages_sent": 0, "messages_received": 0, "active_peers": []}

def log_message(self, direction, peer_id):
if direction == "sent":
self.stats["messages_sent"] += 1
elif direction == "received":
self.stats["messages_received"] += 1
if peer_id not in self.stats["active_peers"]:
self.stats["active_peers"].append(peer_id)

def get_health(self):
return {
"node_id": self.node_id,
"status": "Healthy" if len(self.stats["active_peers"]) > 0 else "Isolated",
"stats": self.stats
}