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:
@ -12,6 +12,8 @@ pub struct ConfirmedBlock {
|
||||
pub rewards: ::prost::alloc::vec::Vec<Reward>,
|
||||
#[prost(message, optional, tag = "6")]
|
||||
pub block_time: ::core::option::Option<UnixTimestamp>,
|
||||
#[prost(message, optional, tag = "7")]
|
||||
pub block_height: ::core::option::Option<BlockHeight>,
|
||||
}
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct ConfirmedTransaction {
|
||||
@ -130,6 +132,11 @@ pub struct UnixTimestamp {
|
||||
#[prost(int64, tag = "1")]
|
||||
pub timestamp: i64,
|
||||
}
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct BlockHeight {
|
||||
#[prost(uint64, tag = "1")]
|
||||
pub block_height: u64,
|
||||
}
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
|
||||
#[repr(i32)]
|
||||
pub enum RewardType {
|
||||
|
@ -66,7 +66,7 @@ pub enum TransactionErrorType {
|
||||
InvalidProgramForExecution = 13,
|
||||
SanitizeFailure = 14,
|
||||
ClusterMaintenance = 15,
|
||||
AccountBorrowOutstanding = 16,
|
||||
AccountBorrowOutstandingTx = 16,
|
||||
}
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
|
||||
#[repr(i32)]
|
||||
|
@ -9,6 +9,7 @@ message ConfirmedBlock {
|
||||
repeated ConfirmedTransaction transactions = 4;
|
||||
repeated Reward rewards = 5;
|
||||
UnixTimestamp block_time = 6;
|
||||
BlockHeight block_height = 7;
|
||||
}
|
||||
|
||||
message ConfirmedTransaction {
|
||||
@ -96,3 +97,7 @@ message Rewards {
|
||||
message UnixTimestamp {
|
||||
int64 timestamp = 1;
|
||||
}
|
||||
|
||||
message BlockHeight {
|
||||
uint64 block_height = 1;
|
||||
}
|
||||
|
@ -118,6 +118,7 @@ impl From<ConfirmedBlock> for generated::ConfirmedBlock {
|
||||
transactions,
|
||||
rewards,
|
||||
block_time,
|
||||
block_height,
|
||||
} = confirmed_block;
|
||||
|
||||
Self {
|
||||
@ -127,6 +128,7 @@ impl From<ConfirmedBlock> for generated::ConfirmedBlock {
|
||||
transactions: transactions.into_iter().map(|tx| tx.into()).collect(),
|
||||
rewards: rewards.into_iter().map(|r| r.into()).collect(),
|
||||
block_time: block_time.map(|timestamp| generated::UnixTimestamp { timestamp }),
|
||||
block_height: block_height.map(|block_height| generated::BlockHeight { block_height }),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -143,6 +145,7 @@ impl TryFrom<generated::ConfirmedBlock> for ConfirmedBlock {
|
||||
transactions,
|
||||
rewards,
|
||||
block_time,
|
||||
block_height,
|
||||
} = confirmed_block;
|
||||
|
||||
Ok(Self {
|
||||
@ -155,6 +158,7 @@ impl TryFrom<generated::ConfirmedBlock> for ConfirmedBlock {
|
||||
.collect::<std::result::Result<Vec<TransactionWithStatusMeta>, Self::Error>>()?,
|
||||
rewards: rewards.into_iter().map(|r| r.into()).collect(),
|
||||
block_time: block_time.map(|generated::UnixTimestamp { timestamp }| timestamp),
|
||||
block_height: block_height.map(|generated::BlockHeight { block_height }| block_height),
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -596,7 +600,7 @@ impl From<TransactionError> for tx_by_addr::TransactionError {
|
||||
tx_by_addr::TransactionErrorType::InstructionError
|
||||
}
|
||||
TransactionError::AccountBorrowOutstanding => {
|
||||
tx_by_addr::TransactionErrorType::AccountBorrowOutstanding
|
||||
tx_by_addr::TransactionErrorType::AccountBorrowOutstandingTx
|
||||
}
|
||||
} as i32,
|
||||
instruction_error: match transaction_error {
|
||||
|
@ -30,7 +30,7 @@ enum TransactionErrorType {
|
||||
PROGRAM_ACCOUNT_NOT_FOUND = 3;
|
||||
INSUFFICIENT_FUNDS_FOR_FEE = 4;
|
||||
INVALID_ACCOUNT_FOR_FEE = 5;
|
||||
DUPLICATE_SIGNATURE = 6;
|
||||
ALREADY_PROCESSED = 6;
|
||||
BLOCKHASH_NOT_FOUND = 7;
|
||||
INSTRUCTION_ERROR = 8;
|
||||
CALL_CHAIN_TOO_DEEP = 9;
|
||||
@ -40,6 +40,7 @@ enum TransactionErrorType {
|
||||
INVALID_PROGRAM_FOR_EXECUTION = 13;
|
||||
SANITIZE_FAILURE = 14;
|
||||
CLUSTER_MAINTENANCE = 15;
|
||||
ACCOUNT_BORROW_OUTSTANDING_TX = 16;
|
||||
}
|
||||
|
||||
message InstructionError {
|
||||
@ -97,6 +98,7 @@ enum InstructionErrorType {
|
||||
ACCOUNT_NOT_RENT_EXEMPT = 45;
|
||||
INVALID_ACCOUNT_OWNER = 46;
|
||||
ARITHMETIC_OVERFLOW = 47;
|
||||
UNSUPPORTED_SYSVAR = 48;
|
||||
}
|
||||
|
||||
message UnixTimestamp {
|
||||
|
Reference in New Issue
Block a user