@@ -23,21 +23,21 @@ use core::{mem, ops::Deref, slice::from_raw_parts};
2323#[ cfg( feature = "std" ) ]
2424use std:: boxed:: Box ;
2525
26- /// SysvarS1otHashes111111111111111111111111111
26+ /// ` SysvarS1otHashes111111111111111111111111111`
2727pub const SLOTHASHES_ID : Pubkey = [
2828 6 , 167 , 213 , 23 , 25 , 47 , 10 , 175 , 198 , 242 , 101 , 227 , 251 , 119 , 204 , 122 , 218 , 130 , 197 , 41 ,
2929 208 , 190 , 59 , 19 , 110 , 45 , 0 , 85 , 32 , 0 , 0 , 0 ,
3030] ;
3131/// Number of bytes in a hash.
3232pub const HASH_BYTES : usize = 32 ;
3333/// Sysvar data is:
34- /// len (8 bytes): little-endian entry count (≤ 512)
35- /// entries( len × 40 bytes): consecutive `(u64 slot, [u8;32] hash)` pairs
34+ /// ` len` (8 bytes): little-endian entry count (` ≤ 512` )
35+ /// ` entries`(` len × 40 bytes` ): consecutive `(u64 slot, [u8;32] hash)` pairs
3636/// Size of the entry count field at the beginning of sysvar data.
3737pub const NUM_ENTRIES_SIZE : usize = mem:: size_of :: < u64 > ( ) ;
3838/// Size of a slot number in bytes.
3939pub const SLOT_SIZE : usize = mem:: size_of :: < Slot > ( ) ;
40- /// Size of a single slot hash entry (slot + hash) .
40+ /// Size of a single slot hash entry.
4141pub const ENTRY_SIZE : usize = SLOT_SIZE + HASH_BYTES ;
4242/// Maximum number of slot hash entries that can be stored in the sysvar.
4343pub const MAX_ENTRIES : usize = 512 ;
@@ -87,7 +87,7 @@ pub(crate) fn read_entry_count_from_bytes(data: &[u8]) -> Option<usize> {
8787/// Reads the entry count from the first 8 bytes of data.
8888///
8989/// # Safety
90- /// Caller must ensure data has at least NUM_ENTRIES_SIZE bytes.
90+ /// Caller must ensure data has at least ` NUM_ENTRIES_SIZE` bytes.
9191#[ inline( always) ]
9292pub ( crate ) unsafe fn read_entry_count_from_bytes_unchecked ( data : & [ u8 ] ) -> usize {
9393 u64:: from_le_bytes ( * ( data. as_ptr ( ) as * const [ u8 ; NUM_ENTRIES_SIZE ] ) ) as usize
@@ -119,7 +119,7 @@ fn parse_and_validate_data(data: &[u8]) -> Result<(), ProgramError> {
119119}
120120
121121impl SlotHashEntry {
122- /// Returns the slot number as a u64.
122+ /// Returns the slot number as a ` u64` .
123123 #[ inline( always) ]
124124 pub fn slot ( & self ) -> Slot {
125125 u64:: from_le_bytes ( self . slot_le )
@@ -130,8 +130,8 @@ impl<T: Deref<Target = [u8]>> SlotHashes<T> {
130130 /// Creates a `SlotHashes` instance with validation of the entry count and buffer size.
131131 ///
132132 /// This constructor validates that the buffer has at least enough bytes to contain
133- /// the declared number of entries. The buffer can be any size >= the minimum required,
134- /// making it suitable for both full MAX_SIZE buffers and smaller test data.
133+ /// the declared number of entries. The buffer can be any size above the minimum required,
134+ /// making it suitable for both full ` MAX_SIZE` buffers and smaller test data.
135135 /// Does not validate that entries are sorted in descending order.
136136 #[ inline( always) ]
137137 pub fn new ( data : T ) -> Result < Self , ProgramError > {
@@ -153,7 +153,7 @@ impl<T: Deref<Target = [u8]>> SlotHashes<T> {
153153 /// This function is unsafe because it does not validate the data size or format.
154154 /// The caller must ensure:
155155 /// 1. The underlying byte slice in `data` represents valid `SlotHashes` data
156- /// (length prefix + entries, where entries are sorted in descending order by slot).
156+ /// (length prefix plus entries, where entries are sorted in descending order by slot).
157157 /// 2. The data slice has at least `NUM_ENTRIES_SIZE + (declared_entries * ENTRY_SIZE)` bytes.
158158 /// 3. The first 8 bytes contain a valid entry count in little-endian format.
159159 ///
@@ -292,8 +292,8 @@ impl SlotHashes<Box<[u8]>> {
292292 /// Fills the provided buffer with the full `SlotHashes` sysvar data.
293293 ///
294294 /// # Safety
295- /// The caller must ensure the buffer pointer is valid for MAX_SIZE bytes.
296- /// The syscall will write exactly MAX_SIZE bytes to the buffer.
295+ /// The caller must ensure the buffer pointer is valid for ` MAX_SIZE` bytes.
296+ /// The syscall will write exactly ` MAX_SIZE` bytes to the buffer.
297297 #[ inline( always) ]
298298 unsafe fn fill_from_sysvar ( buffer_ptr : * mut u8 ) -> Result < ( ) , ProgramError > {
299299 crate :: sysvars:: get_sysvar_unchecked ( buffer_ptr, & SLOTHASHES_ID , 0 , MAX_SIZE ) ?;
0 commit comments