Properly handle block_height in Bigtable bincode deserialization (#17990)
* Default block_height on eof * Add comment to prevent future errors
This commit is contained in:
parent
dbd4dc04b0
commit
c57d1b44ef
|
@ -3,6 +3,7 @@ use log::*;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use solana_sdk::{
|
use solana_sdk::{
|
||||||
clock::{Slot, UnixTimestamp},
|
clock::{Slot, UnixTimestamp},
|
||||||
|
deserialize_utils::default_on_eof,
|
||||||
pubkey::Pubkey,
|
pubkey::Pubkey,
|
||||||
signature::Signature,
|
signature::Signature,
|
||||||
sysvar::is_sysvar_id,
|
sysvar::is_sysvar_id,
|
||||||
|
@ -81,6 +82,9 @@ fn key_to_slot(key: &str) -> Option<Slot> {
|
||||||
// StoredConfirmedBlock holds the same contents as ConfirmedBlock, but is slightly compressed and avoids
|
// StoredConfirmedBlock holds the same contents as ConfirmedBlock, but is slightly compressed and avoids
|
||||||
// some serde JSON directives that cause issues with bincode
|
// some serde JSON directives that cause issues with bincode
|
||||||
//
|
//
|
||||||
|
// Note: in order to continue to support old bincode-serialized bigtable entries, if new fields are
|
||||||
|
// added to ConfirmedBlock, they must either be excluded or set to `default_on_eof` here
|
||||||
|
//
|
||||||
#[derive(Serialize, Deserialize)]
|
#[derive(Serialize, Deserialize)]
|
||||||
struct StoredConfirmedBlock {
|
struct StoredConfirmedBlock {
|
||||||
previous_blockhash: String,
|
previous_blockhash: String,
|
||||||
|
@ -89,6 +93,7 @@ struct StoredConfirmedBlock {
|
||||||
transactions: Vec<StoredConfirmedBlockTransaction>,
|
transactions: Vec<StoredConfirmedBlockTransaction>,
|
||||||
rewards: StoredConfirmedBlockRewards,
|
rewards: StoredConfirmedBlockRewards,
|
||||||
block_time: Option<UnixTimestamp>,
|
block_time: Option<UnixTimestamp>,
|
||||||
|
#[serde(deserialize_with = "default_on_eof")]
|
||||||
block_height: Option<u64>,
|
block_height: Option<u64>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue