parent
81df97a737
commit
2b65011706
@ -20,6 +20,7 @@ use common::*;
|
|||||||
use rlp::*;
|
use rlp::*;
|
||||||
use hashdb::*;
|
use hashdb::*;
|
||||||
use memorydb::*;
|
use memorydb::*;
|
||||||
|
use super::{DB_PREFIX_LEN, LATEST_ERA_KEY, VERSION_KEY};
|
||||||
use super::traits::JournalDB;
|
use super::traits::JournalDB;
|
||||||
use kvdb::{Database, DBTransaction, DatabaseConfig};
|
use kvdb::{Database, DBTransaction, DatabaseConfig};
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
@ -38,17 +39,14 @@ pub struct ArchiveDB {
|
|||||||
latest_era: Option<u64>,
|
latest_era: Option<u64>,
|
||||||
}
|
}
|
||||||
|
|
||||||
// all keys must be at least 12 bytes
|
|
||||||
const LATEST_ERA_KEY : [u8; 12] = [ b'l', b'a', b's', b't', 0, 0, 0, 0, 0, 0, 0, 0 ];
|
|
||||||
const VERSION_KEY : [u8; 12] = [ b'j', b'v', b'e', b'r', 0, 0, 0, 0, 0, 0, 0, 0 ];
|
|
||||||
const DB_VERSION : u32 = 0x103;
|
const DB_VERSION : u32 = 0x103;
|
||||||
|
|
||||||
impl ArchiveDB {
|
impl ArchiveDB {
|
||||||
/// Create a new instance from file
|
/// Create a new instance from file
|
||||||
pub fn new(path: &str) -> ArchiveDB {
|
pub fn new(path: &str) -> ArchiveDB {
|
||||||
let opts = DatabaseConfig {
|
let opts = DatabaseConfig {
|
||||||
//use 12 bytes as prefix, this must match account_db prefix
|
// this must match account_db prefix
|
||||||
prefix_size: Some(12),
|
prefix_size: Some(DB_PREFIX_LEN),
|
||||||
max_open_files: 256,
|
max_open_files: 256,
|
||||||
};
|
};
|
||||||
let backing = Database::open(&opts, path).unwrap_or_else(|e| {
|
let backing = Database::open(&opts, path).unwrap_or_else(|e| {
|
||||||
|
@ -20,6 +20,7 @@ use common::*;
|
|||||||
use rlp::*;
|
use rlp::*;
|
||||||
use hashdb::*;
|
use hashdb::*;
|
||||||
use memorydb::*;
|
use memorydb::*;
|
||||||
|
use super::{DB_PREFIX_LEN, LATEST_ERA_KEY, VERSION_KEY};
|
||||||
use super::traits::JournalDB;
|
use super::traits::JournalDB;
|
||||||
use kvdb::{Database, DBTransaction, DatabaseConfig};
|
use kvdb::{Database, DBTransaction, DatabaseConfig};
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
@ -67,9 +68,6 @@ pub struct EarlyMergeDB {
|
|||||||
latest_era: Option<u64>,
|
latest_era: Option<u64>,
|
||||||
}
|
}
|
||||||
|
|
||||||
// all keys must be at least 12 bytes
|
|
||||||
const LATEST_ERA_KEY : [u8; 12] = [ b'l', b'a', b's', b't', 0, 0, 0, 0, 0, 0, 0, 0 ];
|
|
||||||
const VERSION_KEY : [u8; 12] = [ b'j', b'v', b'e', b'r', 0, 0, 0, 0, 0, 0, 0, 0 ];
|
|
||||||
const DB_VERSION : u32 = 0x003;
|
const DB_VERSION : u32 = 0x003;
|
||||||
const PADDING : [u8; 10] = [ 0u8; 10 ];
|
const PADDING : [u8; 10] = [ 0u8; 10 ];
|
||||||
|
|
||||||
@ -77,8 +75,8 @@ impl EarlyMergeDB {
|
|||||||
/// Create a new instance from file
|
/// Create a new instance from file
|
||||||
pub fn new(path: &str) -> EarlyMergeDB {
|
pub fn new(path: &str) -> EarlyMergeDB {
|
||||||
let opts = DatabaseConfig {
|
let opts = DatabaseConfig {
|
||||||
//use 12 bytes as prefix, this must match account_db prefix
|
// this must match account_db prefix
|
||||||
prefix_size: Some(12),
|
prefix_size: Some(DB_PREFIX_LEN),
|
||||||
max_open_files: 256,
|
max_open_files: 256,
|
||||||
};
|
};
|
||||||
let backing = Database::open(&opts, path).unwrap_or_else(|e| {
|
let backing = Database::open(&opts, path).unwrap_or_else(|e| {
|
||||||
|
@ -79,3 +79,8 @@ pub fn new(path: &str, algorithm: Algorithm) -> Box<JournalDB> {
|
|||||||
Algorithm::RefCounted => Box::new(refcounteddb::RefCountedDB::new(path)),
|
Algorithm::RefCounted => Box::new(refcounteddb::RefCountedDB::new(path)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// all keys must be at least 12 bytes
|
||||||
|
const DB_PREFIX_LEN : usize = 12;
|
||||||
|
const LATEST_ERA_KEY : [u8; DB_PREFIX_LEN] = [ b'l', b'a', b's', b't', 0, 0, 0, 0, 0, 0, 0, 0 ];
|
||||||
|
const VERSION_KEY : [u8; DB_PREFIX_LEN] = [ b'j', b'v', b'e', b'r', 0, 0, 0, 0, 0, 0, 0, 0 ];
|
||||||
|
@ -20,6 +20,7 @@ use common::*;
|
|||||||
use rlp::*;
|
use rlp::*;
|
||||||
use hashdb::*;
|
use hashdb::*;
|
||||||
use memorydb::*;
|
use memorydb::*;
|
||||||
|
use super::{DB_PREFIX_LEN, LATEST_ERA_KEY, VERSION_KEY};
|
||||||
use kvdb::{Database, DBTransaction, DatabaseConfig};
|
use kvdb::{Database, DBTransaction, DatabaseConfig};
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
use std::env;
|
use std::env;
|
||||||
@ -92,9 +93,6 @@ impl Clone for OverlayRecentDB {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// all keys must be at least 12 bytes
|
|
||||||
const LATEST_ERA_KEY : [u8; 12] = [ b'l', b'a', b's', b't', 0, 0, 0, 0, 0, 0, 0, 0 ];
|
|
||||||
const VERSION_KEY : [u8; 12] = [ b'j', b'v', b'e', b'r', 0, 0, 0, 0, 0, 0, 0, 0 ];
|
|
||||||
const DB_VERSION : u32 = 0x203;
|
const DB_VERSION : u32 = 0x203;
|
||||||
const PADDING : [u8; 10] = [ 0u8; 10 ];
|
const PADDING : [u8; 10] = [ 0u8; 10 ];
|
||||||
|
|
||||||
@ -107,8 +105,8 @@ impl OverlayRecentDB {
|
|||||||
/// Create a new instance from file
|
/// Create a new instance from file
|
||||||
pub fn from_prefs(path: &str) -> OverlayRecentDB {
|
pub fn from_prefs(path: &str) -> OverlayRecentDB {
|
||||||
let opts = DatabaseConfig {
|
let opts = DatabaseConfig {
|
||||||
//use 12 bytes as prefix, this must match account_db prefix
|
// this must match account_db prefix
|
||||||
prefix_size: Some(12),
|
prefix_size: Some(DB_PREFIX_LEN),
|
||||||
max_open_files: 256,
|
max_open_files: 256,
|
||||||
};
|
};
|
||||||
let backing = Database::open(&opts, path).unwrap_or_else(|e| {
|
let backing = Database::open(&opts, path).unwrap_or_else(|e| {
|
||||||
|
@ -20,6 +20,7 @@ use common::*;
|
|||||||
use rlp::*;
|
use rlp::*;
|
||||||
use hashdb::*;
|
use hashdb::*;
|
||||||
use overlaydb::*;
|
use overlaydb::*;
|
||||||
|
use super::{DB_PREFIX_LEN, LATEST_ERA_KEY, VERSION_KEY};
|
||||||
use super::traits::JournalDB;
|
use super::traits::JournalDB;
|
||||||
use kvdb::{Database, DBTransaction, DatabaseConfig};
|
use kvdb::{Database, DBTransaction, DatabaseConfig};
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
@ -40,8 +41,6 @@ pub struct RefCountedDB {
|
|||||||
removes: Vec<H256>,
|
removes: Vec<H256>,
|
||||||
}
|
}
|
||||||
|
|
||||||
const LATEST_ERA_KEY : [u8; 12] = [ b'l', b'a', b's', b't', 0, 0, 0, 0, 0, 0, 0, 0 ];
|
|
||||||
const VERSION_KEY : [u8; 12] = [ b'j', b'v', b'e', b'r', 0, 0, 0, 0, 0, 0, 0, 0 ];
|
|
||||||
const DB_VERSION : u32 = 0x200;
|
const DB_VERSION : u32 = 0x200;
|
||||||
const PADDING : [u8; 10] = [ 0u8; 10 ];
|
const PADDING : [u8; 10] = [ 0u8; 10 ];
|
||||||
|
|
||||||
@ -49,8 +48,8 @@ impl RefCountedDB {
|
|||||||
/// Create a new instance given a `backing` database.
|
/// Create a new instance given a `backing` database.
|
||||||
pub fn new(path: &str) -> RefCountedDB {
|
pub fn new(path: &str) -> RefCountedDB {
|
||||||
let opts = DatabaseConfig {
|
let opts = DatabaseConfig {
|
||||||
//use 12 bytes as prefix, this must match account_db prefix
|
// this must match account_db prefix
|
||||||
prefix_size: Some(12),
|
prefix_size: Some(DB_PREFIX_LEN),
|
||||||
max_open_files: 256,
|
max_open_files: 256,
|
||||||
};
|
};
|
||||||
let backing = Database::open(&opts, path).unwrap_or_else(|e| {
|
let backing = Database::open(&opts, path).unwrap_or_else(|e| {
|
||||||
|
Loading…
Reference in New Issue
Block a user