pub struct FlatChainStoreConfig {
pub block_index_size: Option<usize>,
pub headers_file_size: Option<usize>,
pub cache_size: Option<usize>,
pub file_permission: Option<u32>,
pub fork_file_size: Option<usize>,
pub path: String,
}flat-chainstore only.Expand description
Configuration for our flat chain store. See each field for more information
Fields§
§block_index_size: Option<usize>The index map size, in buckets
This index holds our map from block hashes to block heights. We use an open-addressing hash map to map block hashes to block heights. Ideally, size should be way bigger than the number of blocks we expect to have in our chain, therefore reducing the load factor to a negligible value. The default value is having space for 10 million blocks.
We compute the actual capacity by rounding the requested size up to the next power of two,
so we can use hash & (capacity - 1) instead of hash % capacity.
headers_file_size: Option<usize>The size of the headers file map, in headers
This is the size of the flat file that holds all of our block headers. We keep all headers in a simple flat file, one after the other. That file then gets mmaped into RAM, so we can use pointer arithmetic to find specific block, since pos(h) = h * size_of(DiskBlockHeader) The default value is having space for 10 million blocks.
We compute the actual capacity by rounding the requested size up to the next power of two.
cache_size: Option<usize>The size of the cache, in blocks
We keep a LRU cache of the last n blocks we’ve touched. This is to avoid going into the map every time we need to find a block. The default value is 1000 blocks.
file_permission: Option<u32>The permission for all the files we create
This is the permission we give to all the files we create. The default value is 0o660
fork_file_size: Option<usize>The size of the fork headers file map, in headers
This store keeps headers that are not in our main chain, but may be needed sometime. The default value is having space for 10,000 blocks.
We compute the actual capacity by rounding the requested size up to the next power of two.
path: StringThe path where we store our files
We’ll create a few files (namely, the index map, headers file, forks file, and metadata file). We need a directory where we can read and write, it needs at least 880 MiB of free space. And have a file system that supports mmap and sparse files (all the default *unix FS do).
Implementations§
Trait Implementations§
Source§impl Clone for FlatChainStoreConfig
impl Clone for FlatChainStoreConfig
Source§fn clone(&self) -> FlatChainStoreConfig
fn clone(&self) -> FlatChainStoreConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for FlatChainStoreConfig
impl RefUnwindSafe for FlatChainStoreConfig
impl Send for FlatChainStoreConfig
impl Sync for FlatChainStoreConfig
impl Unpin for FlatChainStoreConfig
impl UnwindSafe for FlatChainStoreConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more