Add block height to ConfirmedBlock structs (#17523)
* Add BlockHeight CF to blockstore * Rename CacheBlockTimeService to be more general * Cache block-height using service * Fixup previous proto mishandling * Add block_height to block structs * Add block-height to solana block * Fallback to BankForks if block time or block height are not yet written to Blockstore * Add docs * Review comments
This commit is contained in:
@@ -694,6 +694,7 @@ mod tests {
|
||||
previous_blockhash: Hash::default().to_string(),
|
||||
rewards: vec![],
|
||||
block_time: Some(1_234_567_890),
|
||||
block_height: Some(1),
|
||||
};
|
||||
let bincode_block = compress_best(
|
||||
&bincode::serialize::<StoredConfirmedBlock>(&block.clone().into()).unwrap(),
|
||||
|
@@ -89,6 +89,7 @@ struct StoredConfirmedBlock {
|
||||
transactions: Vec<StoredConfirmedBlockTransaction>,
|
||||
rewards: StoredConfirmedBlockRewards,
|
||||
block_time: Option<UnixTimestamp>,
|
||||
block_height: Option<u64>,
|
||||
}
|
||||
|
||||
impl From<ConfirmedBlock> for StoredConfirmedBlock {
|
||||
@@ -100,6 +101,7 @@ impl From<ConfirmedBlock> for StoredConfirmedBlock {
|
||||
transactions,
|
||||
rewards,
|
||||
block_time,
|
||||
block_height,
|
||||
} = confirmed_block;
|
||||
|
||||
Self {
|
||||
@@ -109,6 +111,7 @@ impl From<ConfirmedBlock> for StoredConfirmedBlock {
|
||||
transactions: transactions.into_iter().map(|tx| tx.into()).collect(),
|
||||
rewards: rewards.into_iter().map(|reward| reward.into()).collect(),
|
||||
block_time,
|
||||
block_height,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -122,6 +125,7 @@ impl From<StoredConfirmedBlock> for ConfirmedBlock {
|
||||
transactions,
|
||||
rewards,
|
||||
block_time,
|
||||
block_height,
|
||||
} = confirmed_block;
|
||||
|
||||
Self {
|
||||
@@ -131,6 +135,7 @@ impl From<StoredConfirmedBlock> for ConfirmedBlock {
|
||||
transactions: transactions.into_iter().map(|tx| tx.into()).collect(),
|
||||
rewards: rewards.into_iter().map(|reward| reward.into()).collect(),
|
||||
block_time,
|
||||
block_height,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user