Skip to content

Commit

Permalink
update sqlx to 0.7 (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
serejkaaa512 authored Nov 13, 2024
1 parent fd8ef4f commit 0725e9e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 24 deletions.
8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
itertools = "0.11.0"
itertools = "0.13"
tokio = { version = "1", features = ["full"] }
transaction-consumer = { git = "https://github.com/broxus/transaction-consumer" }
anyhow = "1.0.38"
anyhow = "1.0"
chrono = { version = "*" }
log = { version = "0.4", features = ["std", "serde"] }
ton_types = { git = "https://github.com/broxus/ton-labs-types" }
ton_block = { git = "https://github.com/broxus/ton-labs-block.git" }
futures = { version = "0.3" }
sqlx = { version = "0.6.2", features = ["runtime-tokio-native-tls", "postgres", "uuid", "offline", "chrono", "json"] }
sqlx = { version = "0.7.4", features = ["runtime-tokio-native-tls", "postgres", "uuid", "chrono", "json"] }
nekoton-abi = { git = "https://github.com/broxus/nekoton.git" }
ton_abi = { git = "https://github.com/broxus/ton-labs-abi.git" }

[dev-dependencies]
env_logger = "0.10.0"
env_logger = "0.11"
env-file-reader = "0.3.0"

24 changes: 9 additions & 15 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::sqlx_client::{
get_count_raw_transactions, get_raw_transactions, insert_raw_transaction,
insert_raw_transactions, update_raw_transactions_set_processed_true,
};
use chrono::NaiveDateTime;
use chrono::DateTime;
use futures::channel::mpsc::{Receiver, Sender};
use futures::SinkExt;
use futures::StreamExt;
Expand Down Expand Up @@ -214,7 +214,7 @@ async fn parse_kafka_transactions(
"COMMIT KAFKA {} transactions timestamp_block {} date: {}",
count,
transaction_time,
NaiveDateTime::from_timestamp_opt(transaction_time, 0).unwrap()
DateTime::from_timestamp(transaction_time, 0).unwrap()
);
count = 0;
*time.write().await = 0;
Expand Down Expand Up @@ -279,7 +279,7 @@ async fn parse_kafka_transactions(
log::info!(
"KAFKA 5_000 transactions timestamp_block {} date: {}",
transaction_timestamp,
NaiveDateTime::from_timestamp_opt(transaction_timestamp as i64, 0).unwrap()
DateTime::from_timestamp(transaction_timestamp as i64, 0).unwrap()
);
i = 0;
}
Expand Down Expand Up @@ -345,13 +345,7 @@ async fn parse_raw_transaction(
for raw_transaction_from_db in raw_transactions_from_db {
i += 1;

let raw_transaction = match RawTransaction::try_from(raw_transaction_from_db) {
Ok(ok) => ok,
Err(e) => {
log::error!("{}", e);
continue;
}
};
let raw_transaction = RawTransaction::from(raw_transaction_from_db);

if let Some(events) = buff_extracted_events(&raw_transaction.data, &parser) {
send_message.push((events, raw_transaction.clone()));
Expand Down Expand Up @@ -493,9 +487,9 @@ pub fn get_exit_code(transaction: &Transaction) -> Option<i32> {

#[cfg(test)]
mod test {
use crate::{extract_events, filter_extracted};
use crate::filter_extracted;
use nekoton_abi::TransactionParser;
use ton_block::{Deserializable, GetRepresentationHash};
use ton_block::Deserializable;

#[test]
fn test_empty() {
Expand All @@ -507,12 +501,12 @@ mod test {

let funs = abi.functions.values().cloned().collect::<Vec<_>>();
let parser = TransactionParser::builder()
.function_in_list(&funs, false)
.functions_out_list(&funs, false)
.function_in_list(funs.clone(), false)
.functions_out_list(funs, false)
.build()
.unwrap();
let test = parser.parse(&tx).unwrap();
let test1 = filter_extracted(test, tx.hash().unwrap(), tx.clone()).unwrap();
let test1 = filter_extracted(test, tx.clone()).unwrap();
dbg!(test1);
}
}
9 changes: 4 additions & 5 deletions src/sqlx_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ pub async fn get_raw_transactions(
args.add(limit);

sqlx::query_with(GET_AND_UPDATE_RAW_TRANSACTIONS_QUERY, args)
.fetch_all(begin)
.fetch_all(&mut **begin)
.await
.map(|y| {
y.into_iter()
Expand Down Expand Up @@ -267,8 +267,7 @@ pub async fn update_raw_transactions_set_processed_true(

#[cfg(test)]
mod test {
use crate::models::RawTransactionFromDb;
use crate::{insert_raw_transactions, update_raw_transactions_set_processed_true};
use crate::update_raw_transactions_set_processed_true;
use sqlx::PgPool;

#[tokio::test]
Expand All @@ -277,10 +276,10 @@ mod test {
.await
.unwrap();

let times = (vec![
let times = vec![
(1656071372, 27915771000001_i64),
(1656070201, 27915328000006),
]);
];
update_raw_transactions_set_processed_true(&pg_pool, times).await;
}
}

0 comments on commit 0725e9e

Please sign in to comment.