mirror of
https://github.com/jwinterm/grin-wallet.git
synced 2026-10-23 18:18:31 +02:00
* config: global instance * fix: cli tests * fix: owner api tests * config: save tor config * fix: owner rpc tests * fix: set config file path on init and owner api call * tor: store launched services, get global config at command loop, remove unused listen args, check for empty global config to set default, do not save empty tor config at owner * api: update config in memory after successful file write * arti: restart proxy in loop * fix: comment for tor config save * config: set or init, update without error * config: scoped tor config * build: update lock file * config: ability to store multiple configurations at memory from config path * tor: restart service on config change * fix: owner api test * foreign: pass tor config from args, stop service, error handling * arti: move runtime wrapper to single file * config: read existing config from file at create_config * config: handle error on read * arti: single dir for cache * foreign: register config listener before launch * config: save temp * config: remove unused error type * config: make path and members not optional, return an error on config creation if it exists, pass default tor config to send if not set * arti: non public runtime wrapper * config: migrate comments * fix: rpc tests * config: return from cache if exists * config: save disabled tor config when null provided at owner and tor section was not set * config: update tor with args at listener * config: pass pathbuf directly on creation * config: unique tmp file name, setting permissions and providing config version * fix global config handling * fix config persistence * fix tor service restart * fix config synchronization * require wallet close before changing data directory * unify global config updates --------- Co-authored-by: wiesche <wiesche89@googlemail.com>
46 lines
1.3 KiB
Rust
46 lines
1.3 KiB
Rust
// Copyright 2026 The Grin Developers
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
use crate::config::TorConfig;
|
|
use crate::libwallet::Error;
|
|
use crate::util::Mutex;
|
|
use grin_wallet_config::config::get_global_config;
|
|
use std::path::{Path, PathBuf};
|
|
use std::sync::Arc;
|
|
|
|
/// Shared path to the active wallet configuration.
|
|
#[doc(hidden)]
|
|
#[derive(Clone)]
|
|
pub struct ConfigPath(Arc<Mutex<PathBuf>>);
|
|
|
|
impl ConfigPath {
|
|
pub(crate) fn get(&self) -> PathBuf {
|
|
self.0.lock().clone()
|
|
}
|
|
|
|
pub(crate) fn set(&self, path: PathBuf) {
|
|
*self.0.lock() = path;
|
|
}
|
|
}
|
|
|
|
impl From<PathBuf> for ConfigPath {
|
|
fn from(path: PathBuf) -> Self {
|
|
Self(Arc::new(Mutex::new(path)))
|
|
}
|
|
}
|
|
|
|
pub(crate) fn load(config_path: &Path) -> Result<TorConfig, Error> {
|
|
Ok(get_global_config(config_path)?.tor_config())
|
|
}
|