@@ -65,7 +65,10 @@ mod price_pythnet {
6565 /// Minimum valid publisher quotes for a succesful aggregation
6666 pub min_pub_ : u8 ,
6767 pub message_sent_ : u8 ,
68- pub unused_2_ : i16 ,
68+ /// Configurable max latency in slots between send and receive
69+ pub max_latency_ : u8 ,
70+ /// Unused placeholder for alignment
71+ pub unused_2_ : i8 ,
6972 pub unused_3_ : i32 ,
7073 /// Corresponding product account
7174 pub product_account : Pubkey ,
@@ -116,6 +119,7 @@ mod price_pythnet {
116119 self . agg_ . price_ ,
117120 self . agg_ . conf_ ,
118121 self . agg_ . pub_slot_ . saturating_sub ( self . prev_slot_ ) ,
122+ self . max_latency_ ,
119123 ) ; // pub_slot should always be >= prev_slot, but we protect ourselves against underflow just in case
120124 Ok ( ( ) )
121125 } else {
@@ -172,11 +176,13 @@ mod price_pythnet {
172176 }
173177
174178 impl PriceCumulative {
175- pub fn update ( & mut self , price : i64 , conf : u64 , slot_gap : u64 ) {
179+ pub fn update ( & mut self , price : i64 , conf : u64 , slot_gap : u64 , max_latency : i16 ) {
176180 self . price += i128:: from ( price) * i128:: from ( slot_gap) ;
177181 self . conf += u128:: from ( conf) * u128:: from ( slot_gap) ;
182+ // Use PC_MAX_SEND_LATENCY if max_latency is 0, otherwise use max_latency
183+ let latency = if max_latency == 0 { PC_MAX_SEND_LATENCY . into ( ) } else { max_latency. into ( ) } ;
178184 // This is expected to saturate at 0 most of the time (while the feed is up).
179- self . num_down_slots += slot_gap. saturating_sub ( PC_MAX_SEND_LATENCY . into ( ) ) ;
185+ self . num_down_slots += slot_gap. saturating_sub ( latency as u64 ) ;
180186 }
181187 }
182188}
@@ -225,7 +231,10 @@ mod price_solana {
225231 /// Whether the current aggregate price has been sent as a message to the message buffer.
226232 /// 0 = false, 1 = true. (this is a u8 to make the Pod trait happy)
227233 pub message_sent_ : u8 ,
228- pub unused_2_ : i16 ,
234+ /// Configurable max latency in slots between send and receive
235+ pub max_latency_ : u8 ,
236+ /// Unused placeholder for alignment
237+ pub unused_2_ : i8 ,
229238 pub unused_3_ : i32 ,
230239 /// Corresponding product account
231240 pub product_account : Pubkey ,
0 commit comments