miden_node_store/
config.rs

1use std::{
2    fmt::{Display, Formatter},
3    path::PathBuf,
4};
5
6use miden_node_utils::config::{Endpoint, DEFAULT_STORE_PORT};
7use serde::{Deserialize, Serialize};
8
9// Main config
10// ================================================================================================
11
12#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Serialize, Deserialize)]
13#[serde(deny_unknown_fields)]
14pub struct StoreConfig {
15    /// Defines the listening socket.
16    pub endpoint: Endpoint,
17    /// `SQLite` database file
18    pub database_filepath: PathBuf,
19    /// Genesis file
20    pub genesis_filepath: PathBuf,
21    /// Block store directory
22    pub blockstore_dir: PathBuf,
23}
24
25impl StoreConfig {
26    pub fn endpoint_url(&self) -> String {
27        self.endpoint.to_string()
28    }
29}
30
31impl Display for StoreConfig {
32    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
33        f.write_fmt(format_args!(
34            "{{ endpoint: \"{}\",  database_filepath: {:?}, genesis_filepath: {:?}, blockstore_dir: {:?} }}",
35            self.endpoint, self.database_filepath, self.genesis_filepath, self.blockstore_dir
36        ))
37    }
38}
39
40impl Default for StoreConfig {
41    fn default() -> Self {
42        const NODE_STORE_DIR: &str = "./";
43        Self {
44            endpoint: Endpoint::localhost(DEFAULT_STORE_PORT),
45            database_filepath: PathBuf::from(NODE_STORE_DIR.to_string() + "miden-store.sqlite3"),
46            genesis_filepath: PathBuf::from(NODE_STORE_DIR.to_string() + "genesis.dat"),
47            blockstore_dir: PathBuf::from(NODE_STORE_DIR.to_string() + "blocks"),
48        }
49    }
50}