ant_protocol/
node.rs

1// Copyright 2024 MaidSafe.net limited.
2//
3// This SAFE Network Software is licensed to you under The General Public License (GPL), version 3.
4// Unless required by applicable law or agreed to in writing, the SAFE Network Software distributed
5// under the GPL Licence is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
6// KIND, either express or implied. Please review the Licences for the specific language governing
7// permissions and limitations relating to use of the SAFE Network Software.
8
9use crate::error::{Error, Result};
10use libp2p::PeerId;
11use std::path::PathBuf;
12
13/// Get the default antnode root dir for the provided PeerId
14pub fn get_antnode_root_dir(peer_id: PeerId) -> Result<PathBuf> {
15    let dir = dirs_next::data_dir()
16        .ok_or_else(|| Error::CouldNotObtainDataDir)?
17        .join("autonomi")
18        .join("node")
19        .join(peer_id.to_string());
20    Ok(dir)
21}