making proper types

This commit is contained in:
Godmode Galactus 2023-10-21 18:40:19 +02:00
parent f072b3ce3c
commit fd8fa7fe05
No known key found for this signature in database
GPG Key ID: A04142C71ABB0DEA
3 changed files with 38 additions and 13 deletions

View File

@ -1,21 +1,37 @@
CREATE SCHEMA banking_stage_results;
CREATE TYPE error AS (
error text,
slot BIGINT,
count BIGINT
);
CREATE TYPE ACCOUNT_USED AS (
account CHAR(44),
r_w CHAR
);
CREATE TYPE ACCOUNT_USE_COUNT AS (
account CHAR(44),
cu BIGINT
);
CREATE TABLE banking_stage_results.transaction_infos (
signature CHAR(88) NOT NULL,
signature CHAR(88) PRIMARY KEY,
message text,
errors text,
errors ERROR[],
is_executed BOOL,
is_confirmed BOOL,
first_notification_slot BIGINT NOT NULL,
cu_requested BIGINT,
prioritization_fees BIGINT,
utc_timestamp TIMESTAMP WITH TIME ZONE NOT NULL,
accounts_used text[]
processed_slot BIGINT,
accounts_used ACCOUNT_USED[],
processed_slot BIGINT
);
CREATE TABLE banking_stage_results.blocks (
block_hash CHAR(44) NOT NULL,
block_hash CHAR(44) PRIMARY KEY,
slot BIGINT,
leader_identity CHAR(44),
successful_transactions BIGINT,
@ -23,7 +39,15 @@ CREATE TABLE banking_stage_results.blocks (
processed_transactions BIGINT,
total_cu_used BIGINT,
total_cu_requested BIGINT,
heavily_writelocked_accounts text[]
heavily_writelocked_accounts ACCOUNT_USE_COUNT[]
);
CREATE TABLE banking_stage_results.accounts (
account CHAR(44) PRIMARY KEY,
account_borrow_outstanding BIGINT,
account_in_use_write BIGINT,
account_in_use_read BIGINT,
would_exceed_maximum_account_cost_limit BIGINT
);

View File

@ -202,7 +202,7 @@ impl BlockInfo {
heavily_writelocked_accounts.sort_by(|lhs, rhs| (*rhs.1).cmp(lhs.1));
let heavily_writelocked_accounts = heavily_writelocked_accounts
.iter()
.map(|(pubkey, cu)| format!("{}:{}", **pubkey, **cu))
.map(|(pubkey, cu)| format!("({}, {})", **pubkey, **cu))
.collect_vec();
BlockInfo {
block_hash,

View File

@ -200,7 +200,7 @@ impl Postgres {
pub struct PostgresTransactionInfo {
pub signature: String,
pub transaction_message: Option<String>,
pub errors: String,
pub errors: Vec<String>,
pub is_executed: bool,
pub is_confirmed: bool,
pub first_notification_slot: i64,
@ -213,14 +213,15 @@ pub struct PostgresTransactionInfo {
impl From<&TransactionInfo> for PostgresTransactionInfo {
fn from(value: &TransactionInfo) -> Self {
let errors = value.errors.iter().fold(String::new(), |is, x| {
let str = is + x.0.to_string().as_str() + ":" + x.1.to_string().as_str() + ";";
str
});
let errors = value
.errors
.iter()
.map(|(key, size)| format!("({}, {}, {})", key.error, key.slot, size))
.collect_vec();
let accounts_used = value
.account_used
.iter()
.map(|x| format!("{}({})", x.0, x.1).to_string())
.map(|x| format!("({}, {})", x.0, x.1))
.collect();
Self {
signature: value.signature.clone(),