solana_central/central_context/
fetch_current_slot_blockhash.rs

1use crate::central_context::central_context::CentralContext;
2
3impl CentralContext {
4  /// Refresh current slot and latest blockhash from JSON RPC
5  ///
6  /// Updates the `current_slot` and `latest_blockhash` fields in the context.
7  /// Note: In production, these values are typically updated via gRPC streams rather than polling.
8  pub fn fetch_current_slot_blockhash(&self) {
9    let mut current_slot = self.current_slot.write().unwrap();
10    *current_slot = self.json_rpc_client.get_slot().unwrap();
11    let mut latest_blockhash = self.latest_blockhash.write().unwrap();
12    *latest_blockhash = self.json_rpc_client.get_latest_blockhash().unwrap();
13  }
14}