state: add SLED_FORMAT_VERSION prefix to db path
Also removes a redundant test.
This commit is contained in:
parent
d7e8217d8a
commit
dace92aca1
|
|
@ -61,7 +61,12 @@ impl Config {
|
||||||
if self.ephemeral {
|
if self.ephemeral {
|
||||||
config.temporary(self.ephemeral)
|
config.temporary(self.ephemeral)
|
||||||
} else {
|
} else {
|
||||||
let path = self.cache_dir.join(net_dir).join("state");
|
let path = self
|
||||||
|
.cache_dir
|
||||||
|
.join("state")
|
||||||
|
.join(format!("v{}", crate::constants::SLED_FORMAT_VERSION))
|
||||||
|
.join(net_dir);
|
||||||
|
|
||||||
config.path(path)
|
config.path(path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,3 +13,5 @@ pub const MIN_TRASPARENT_COINBASE_MATURITY: block::Height = block::Height(100);
|
||||||
/// coinbase transactions.
|
/// coinbase transactions.
|
||||||
pub const MAX_BLOCK_REORG_HEIGHT: block::Height =
|
pub const MAX_BLOCK_REORG_HEIGHT: block::Height =
|
||||||
block::Height(MIN_TRASPARENT_COINBASE_MATURITY.0 - 1);
|
block::Height(MIN_TRASPARENT_COINBASE_MATURITY.0 - 1);
|
||||||
|
|
||||||
|
pub const SLED_FORMAT_VERSION: u32 = 0;
|
||||||
|
|
|
||||||
|
|
@ -1,36 +1,7 @@
|
||||||
use std::ffi::OsStr;
|
use zebra_chain::block;
|
||||||
|
|
||||||
use zebra_chain::{block, parameters::Network};
|
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_path_mainnet() {
|
|
||||||
test_path(Network::Mainnet);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_path_testnet() {
|
|
||||||
test_path(Network::Testnet);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Check the sled path for `network`.
|
|
||||||
fn test_path(network: Network) {
|
|
||||||
zebra_test::init();
|
|
||||||
|
|
||||||
let config = Config::default();
|
|
||||||
// we can't do many useful tests on this value, because it depends on the
|
|
||||||
// local environment and OS.
|
|
||||||
let sled_config = config.sled_config(network);
|
|
||||||
let mut path = sled_config.get_path();
|
|
||||||
assert_eq!(path.file_name(), Some(OsStr::new("state")));
|
|
||||||
assert!(path.pop());
|
|
||||||
match network {
|
|
||||||
Network::Mainnet => assert_eq!(path.file_name(), Some(OsStr::new("mainnet"))),
|
|
||||||
Network::Testnet => assert_eq!(path.file_name(), Some(OsStr::new("testnet"))),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Block heights, and the expected minimum block locator height
|
/// Block heights, and the expected minimum block locator height
|
||||||
static BLOCK_LOCATOR_CASES: &[(u32, u32)] = &[
|
static BLOCK_LOCATOR_CASES: &[(u32, u32)] = &[
|
||||||
(0, 0),
|
(0, 0),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue