use lightning::util::logger::Logger;
use lightning::util::ser::Writeable;
use tokio::sync::mpsc;
-use tokio_postgres::NoTls;
use crate::config;
use crate::types::GossipMessage;
}
pub(crate) async fn persist_gossip(&mut self) {
- let connection_config = config::db_connection_config();
- let (mut client, connection) =
- connection_config.connect(NoTls).await.unwrap();
-
- tokio::spawn(async move {
- if let Err(e) = connection.await {
- panic!("connection error: {}", e);
- }
- });
+ let mut client = crate::connect_to_db().await;
{
// initialize the database
config::upgrade_db(cur_schema[0].get(0), &mut client).await;
}
+ let preparation = client.execute("set time zone UTC", &[]).await;
+ if let Err(preparation_error) = preparation {
+ panic!("db preparation error: {}", preparation_error);
+ }
+
let initialization = client
.execute(
// TODO: figure out a way to fix the id value without Postgres complaining about