arbos/block_metadata.rs
1/// Per-block metadata byte array.
2///
3/// Format: first byte is version (currently 0), subsequent bytes are
4/// bit-packed flags indicating which transactions were timeboosted.
5#[derive(Debug, Clone, Default)]
6pub struct BlockMetadata(pub Vec<u8>);
7
8impl BlockMetadata {
9 pub fn new(data: Vec<u8>) -> Self {
10 Self(data)
11 }
12
13 /// Returns whether the transaction at `tx_index` was timeboosted.
14 ///
15 /// Returns `None` if the metadata is empty or too short to cover the index.
16 pub fn is_tx_timeboosted(&self, tx_index: usize) -> Option<bool> {
17 if self.0.is_empty() {
18 return None;
19 }
20 // First byte is version, remaining bytes are bit flags.
21 let byte_index = 1 + tx_index / 8;
22 let bit_index = tx_index % 8;
23 if byte_index >= self.0.len() {
24 return Some(false);
25 }
26 Some(self.0[byte_index] & (1 << bit_index) != 0)
27 }
28}