Skip to content
Closed
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
4 changes: 2 additions & 2 deletions node/rustchain_p2p_gossip.py
Original file line number Diff line number Diff line change
Expand Up @@ -880,10 +880,10 @@ def _handle_get_state(self, msg: GossipMessage) -> Dict:
"balances": self.balance_crdt.to_dict()
}
# Sign the state response so the requester can verify authenticity.
# Uses the Phase A signed-content shape (msg_type:sender_id:payload)
# Uses the updated signature shape (msg_type:sender_id:msg_id:ttl:payload) per #2256
# so verify_message() on the requester side accepts it.
payload = {"state": state_data}
content = self._signed_content(MessageType.STATE.value, self.node_id, payload)
content = self._signed_content(MessageType.STATE.value, self.node_id, msg.msg_id, msg.ttl, payload)
signature, timestamp = self._sign_message(content)
return {
"status": "ok",
Expand Down
6 changes: 3 additions & 3 deletions node/rustchain_p2p_sync_secure.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ class RateLimiter:

def __init__(self):
self.requests = {} # {peer_url: [(timestamp, endpoint), ...]}
self.lock = threading.Lock()
self.lock = threading.RLock()

# Rate limits per endpoint (requests per minute)
self.limits = {
Expand Down Expand Up @@ -291,7 +291,7 @@ def __init__(self, max_peers: int = 50):
self.peer_reputation = {} # {peer_url: score}
self.banned_peers = set()
self.whitelist = set()
self.lock = threading.Lock()
self.lock = threading.RLock()

def can_add_peer(self, peer_url: str) -> tuple:
"""Check if peer can be added"""
Expand Down Expand Up @@ -344,7 +344,7 @@ def __init__(self, db_path: str, local_host: str, local_port: int = 8088):
self.local_port = local_port
self.local_url = f"http://{local_host}:{local_port}"
self.peers: Dict[str, Dict] = {}
self.lock = threading.Lock()
self.lock = threading.RLock()

# Security components
self.auth_manager = P2PAuthManager()
Expand Down