fixing error for first request

This commit is contained in:
Godmode Galactus 2023-10-16 15:53:44 +02:00
parent 177e68a514
commit 29616a19c9
No known key found for this signature in database
GPG Key ID: A04142C71ABB0DEA
3 changed files with 22 additions and 8 deletions

View File

@ -2,8 +2,8 @@ CREATE SCHEMA banking_stage_results;
CREATE TABLE banking_stage_results.transaction_infos ( CREATE TABLE banking_stage_results.transaction_infos (
signature CHAR(88) NOT NULL, signature CHAR(88) NOT NULL,
message CHAR(1280), message text,
errors CHAR(10000) NOT NULL, errors text,
is_executed BOOL, is_executed BOOL,
is_confirmed BOOL, is_confirmed BOOL,
first_notification_slot BIGINT NOT NULL, first_notification_slot BIGINT NOT NULL,

View File

@ -68,9 +68,11 @@ async fn main() {
x.add_notification(&transaction); x.add_notification(&transaction);
} }
None => { None => {
let mut x = TransactionInfo::new(&transaction);
x.add_notification(&transaction);
map_of_infos.insert( map_of_infos.insert(
sig, sig,
TransactionInfo::new(transaction.signature, transaction.slot), x,
); );
} }
} }

View File

@ -79,14 +79,26 @@ pub struct TransactionInfo {
} }
impl TransactionInfo { impl TransactionInfo {
pub fn new(signature: String, first_notification_slot: Slot) -> Self { pub fn new(notification: &SubscribeUpdateBankingTransactionResults) -> Self {
let mut errors = HashMap::new();
let is_executed = notification.error.is_none();
match &notification.error {
Some(e) => {
let error: TransactionError = bincode::deserialize(&e.err).unwrap();
let key = ErrorKey { error, slot: notification.slot };
errors.insert( key, 1);
},
None => {
}
};
Self { Self {
signature, signature: notification.signature.clone(),
transaction_message: None, transaction_message: None,
errors: HashMap::new(), errors,
is_executed: false, is_executed,
is_confirmed: false, is_confirmed: false,
first_notification_slot, first_notification_slot: notification.slot,
cu_requested: None, cu_requested: None,
prioritization_fees: None, prioritization_fees: None,
} }