Skip to content

Commit

Permalink
Support v1.16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
lijunwangs committed Oct 17, 2023
1 parent cc14693 commit d2f44a3
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ authors = ["Solana Maintainers <[email protected]>"]
edition = "2021"
name = "solana-geyser-plugin-postgres"
description = "The Solana AccountsDb plugin for PostgreSQL database."
version = "1.15.2"
version = "1.16.0"
repository = "https://github.com/solana-labs/solana-accountsdb-plugin-postgres"
license = "Apache-2.0"
homepage = "https://solana.com/"
Expand Down
4 changes: 3 additions & 1 deletion scripts/create_schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ Create TYPE "TransactionErrorCode" AS ENUM (
'InsufficientFundsForRent',
'MaxLoadedAccountsDataSizeExceeded',
'InvalidLoadedAccountsDataSizeLimit',
'ResanitizationNeeded'
'ResanitizationNeeded',
'ProgramExecutionTemporarilyRestricted',
'UnbalancedTransaction'
);

CREATE TYPE "TransactionError" AS (
Expand Down
7 changes: 6 additions & 1 deletion src/geyser_plugin_postgres.rs
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ impl GeyserPlugin for GeyserPluginPostgres {
)));
}
Some(client) => match block_info {
ReplicaBlockInfoVersions::V0_0_2(block_info) => {
ReplicaBlockInfoVersions::V0_0_3(block_info) => {
let result = client.update_block_metadata(block_info);

if let Err(err) = result {
Expand All @@ -423,6 +423,11 @@ impl GeyserPlugin for GeyserPluginPostgres {
});
}
}
ReplicaBlockInfoVersions::V0_0_2(_block_info) => {
return Err(GeyserPluginError::SlotStatusUpdateError{
msg: "Failed to persist the transaction info to the PostgreSQL database. Unsupported format.".to_string()
});
}
ReplicaBlockInfoVersions::V0_0_1(_) => {
return Err(GeyserPluginError::SlotStatusUpdateError{
msg: "Failed to persist the transaction info to the PostgreSQL database. Unsupported format.".to_string()
Expand Down
4 changes: 2 additions & 2 deletions src/postgres_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use {
postgres_client_transaction::LogTransactionRequest,
postgres_openssl::MakeTlsConnector,
solana_geyser_plugin_interface::geyser_plugin_interface::{
GeyserPluginError, ReplicaAccountInfoV3, ReplicaBlockInfoV2, SlotStatus,
GeyserPluginError, ReplicaAccountInfoV3, ReplicaBlockInfoV3, SlotStatus,
},
solana_measure::measure::Measure,
solana_metrics::*,
Expand Down Expand Up @@ -1232,7 +1232,7 @@ impl ParallelPostgresClient {

pub fn update_block_metadata(
&self,
block_info: &ReplicaBlockInfoV2,
block_info: &ReplicaBlockInfoV3,
) -> Result<(), GeyserPluginError> {
if let Err(err) = self.sender.send(DbWorkItem::UpdateBlockMetadata(Box::new(
UpdateBlockMetadataRequest {
Expand Down
6 changes: 3 additions & 3 deletions src/postgres_client/postgres_client_block_metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use {
log::*,
postgres::{Client, Statement},
solana_geyser_plugin_interface::geyser_plugin_interface::{
GeyserPluginError, ReplicaBlockInfoV2,
GeyserPluginError, ReplicaBlockInfoV3,
},
};

Expand All @@ -22,8 +22,8 @@ pub struct DbBlockInfo {
pub block_height: Option<i64>,
}

impl<'a> From<&ReplicaBlockInfoV2<'a>> for DbBlockInfo {
fn from(block_info: &ReplicaBlockInfoV2) -> Self {
impl<'a> From<&ReplicaBlockInfoV3<'a>> for DbBlockInfo {
fn from(block_info: &ReplicaBlockInfoV3) -> Self {
Self {
slot: block_info.slot as i64,
blockhash: block_info.blockhash.to_string(),
Expand Down
4 changes: 4 additions & 0 deletions src/postgres_client/postgres_client_transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,8 @@ pub enum DbTransactionErrorCode {
MaxLoadedAccountsDataSizeExceeded,
InvalidLoadedAccountsDataSizeLimit,
ResanitizationNeeded,
ProgramExecutionTemporarilyRestricted,
UnbalancedTransaction,
}

impl From<&TransactionError> for DbTransactionErrorCode {
Expand Down Expand Up @@ -407,6 +409,8 @@ impl From<&TransactionError> for DbTransactionErrorCode {
Self::InvalidLoadedAccountsDataSizeLimit
}
TransactionError::ResanitizationNeeded => Self::ResanitizationNeeded,
TransactionError::ProgramExecutionTemporarilyRestricted {account_index: _} => Self::ProgramExecutionTemporarilyRestricted,
TransactionError::UnbalancedTransaction => Self::UnbalancedTransaction,
}
}
}
Expand Down

0 comments on commit d2f44a3

Please sign in to comment.