Skip to content

Commit 5269241

Browse files
committed
add sqlite connection to signer
1 parent b7a81e5 commit 5269241

File tree

6 files changed

+20
-15
lines changed

6 files changed

+20
-15
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mithril-aggregator/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "mithril-aggregator"
3-
version = "0.2.31"
3+
version = "0.2.32"
44
description = "A Mithril Aggregator server"
55
authors = { workspace = true }
66
edition = { workspace = true }

mithril-aggregator/src/command_args.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -344,13 +344,11 @@ impl ServeCommand {
344344
.try_deserialize()
345345
.map_err(|e| format!("configuration deserialize error: {e}"))?;
346346
debug!("SERVE command"; "config" => format!("{config:?}"));
347-
let sqlite_db_path = Some(config.get_sqlite_file());
348347
check_database_migration(config.get_sqlite_file())?;
349348

350349
// Init dependencies
351-
let sqlite_connection = Arc::new(Mutex::new(Connection::open(
352-
sqlite_db_path.clone().unwrap(),
353-
)?));
350+
let sqlite_db_path = config.get_sqlite_file();
351+
let sqlite_connection = Arc::new(Mutex::new(Connection::open(sqlite_db_path)?));
354352
let snapshot_store = Arc::new(LocalSnapshotStore::new(
355353
Box::new(SQLiteAdapter::new("snapshot", sqlite_connection.clone())?),
356354
LIST_SNAPSHOTS_MAX_ITEMS,

mithril-common/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "mithril-common"
3-
version = "0.2.26"
3+
version = "0.2.27"
44
authors = { workspace = true }
55
edition = { workspace = true }
66
documentation = { workspace = true }

mithril-signer/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "mithril-signer"
3-
version = "0.2.22"
3+
version = "0.2.23"
44
description = "A Mithril Signer"
55
authors = { workspace = true }
66
edition = { workspace = true }
@@ -24,6 +24,7 @@ slog = { version = "2.7.0", features = ["max_level_trace", "release_max_level_de
2424
slog-async = "2.7.0"
2525
slog-bunyan = "2.4.0"
2626
slog-scope = "4.4.0"
27+
sqlite = "0.28"
2728
thiserror = "1.0.31"
2829
tokio = { version = "1.17.0", features = ["full"] }
2930

mithril-signer/src/runtime/signer_services.rs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
use async_trait::async_trait;
2-
use std::{fs, sync::Arc};
3-
4-
use mithril_common::digesters::{
5-
cache::{ImmutableFileDigestCacheProvider, JsonImmutableFileDigestCacheProviderBuilder},
6-
ImmutableFileObserver,
2+
use sqlite::Connection;
3+
use std::{
4+
fs,
5+
sync::{Arc, Mutex},
76
};
7+
88
use mithril_common::{
99
chain_observer::{CardanoCliChainObserver, CardanoCliRunner, ChainObserver},
1010
crypto_helper::{OpCert, ProtocolPartyId, SerDeShelleyFileFormat},
11+
digesters::{
12+
cache::{ImmutableFileDigestCacheProvider, JsonImmutableFileDigestCacheProviderBuilder},
13+
ImmutableFileObserver,
14+
},
1115
digesters::{CardanoImmutableDigester, ImmutableDigester, ImmutableFileSystemObserver},
1216
era::{EraChecker, EraReader},
1317
store::{adapter::SQLiteAdapter, StakeStore},
@@ -138,11 +142,12 @@ impl<'a> ServiceBuilder for ProductionServiceBuilder<'a> {
138142
.map_err(|e| format!("Could not create data stores directory: {e:?}"))?;
139143
}
140144

141-
let sqlite_db_path = Some(self.config.get_sqlite_file());
145+
let sqlite_db_path = self.config.get_sqlite_file();
146+
let sqlite_connection = Arc::new(Mutex::new(Connection::open(sqlite_db_path)?));
142147
let protocol_initializer_store = Arc::new(ProtocolInitializerStore::new(
143148
Box::new(SQLiteAdapter::new(
144149
"protocol_initializer",
145-
sqlite_db_path.clone(),
150+
sqlite_connection.clone(),
146151
)?),
147152
self.config.store_retention_limit,
148153
));
@@ -156,7 +161,7 @@ impl<'a> ServiceBuilder for ProductionServiceBuilder<'a> {
156161
slog_scope::logger(),
157162
));
158163
let stake_store = Arc::new(StakeStore::new(
159-
Box::new(SQLiteAdapter::new("stake", sqlite_db_path)?),
164+
Box::new(SQLiteAdapter::new("stake", sqlite_connection)?),
160165
self.config.store_retention_limit,
161166
));
162167
let chain_observer = {

0 commit comments

Comments
 (0)