@@ -727,6 +727,7 @@ pub enum QueryResponse {
727727 ConnectedPeers { peers : Vec < ( Peer , SocketAddr ) > } ,
728728 NetworkDebug ( NetworkDebugInfo ) ,
729729 NodeDiagnostics ( NodeDiagnosticsResponse ) ,
730+ ProximityCache ( ProximityCacheInfo ) ,
730731}
731732
732733#[ derive( Serialize , Deserialize , Debug , Clone ) ]
@@ -806,6 +807,57 @@ pub enum NodeQuery {
806807 /// Diagnostic configuration specifying what information to collect
807808 config : NodeDiagnosticsConfig ,
808809 } ,
810+ /// Phase 3: Query proximity cache information for update propagation
811+ ProximityCacheInfo ,
812+ }
813+
814+ /// Phase 3: Proximity cache information for update propagation
815+ #[ derive( Serialize , Deserialize , Debug , Clone ) ]
816+ pub struct ProximityCacheInfo {
817+ /// Contracts this node is currently caching
818+ pub my_cache : Vec < ContractCacheEntry > ,
819+ /// What we know about neighbor caches
820+ pub neighbor_caches : Vec < NeighborCacheInfo > ,
821+ /// Proximity propagation statistics
822+ pub stats : ProximityStats ,
823+ }
824+
825+ #[ derive( Serialize , Deserialize , Debug , Clone ) ]
826+ pub struct ContractCacheEntry {
827+ /// Full contract key as string
828+ pub contract_key : String ,
829+ /// 32-bit hash for proximity matching
830+ pub cache_hash : u32 ,
831+ /// When this contract was cached (Unix timestamp)
832+ pub cached_since : u64 ,
833+ }
834+
835+ #[ derive( Serialize , Deserialize , Debug , Clone ) ]
836+ pub struct NeighborCacheInfo {
837+ /// Peer identifier
838+ pub peer_id : String ,
839+ /// Contract hashes this neighbor is known to cache
840+ pub known_contracts : Vec < u32 > ,
841+ /// Last update received from this neighbor (Unix timestamp)
842+ pub last_update : u64 ,
843+ /// Number of updates received from this neighbor
844+ pub update_count : u64 ,
845+ }
846+
847+ #[ derive( Serialize , Deserialize , Debug , Clone ) ]
848+ pub struct ProximityStats {
849+ /// Number of cache announcements sent
850+ pub cache_announces_sent : u64 ,
851+ /// Number of cache announcements received
852+ pub cache_announces_received : u64 ,
853+ /// Updates forwarded via proximity (not subscription)
854+ pub updates_via_proximity : u64 ,
855+ /// Updates forwarded via subscription
856+ pub updates_via_subscription : u64 ,
857+ /// False positives due to hash collisions
858+ pub false_positive_forwards : u64 ,
859+ /// Average number of contracts per neighbor
860+ pub avg_neighbor_cache_size : f32 ,
809861}
810862
811863#[ derive( Serialize , Deserialize , Debug , Clone ) ]
0 commit comments