Struct FlatChainStoreConfig

Source
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,
}
Available on crate feature 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: String

The 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§

Source§

impl FlatChainStoreConfig

Source

pub fn new(path: String) -> Self

Creates a new configuration with the default values

Trait Implementations§

Source§

impl Clone for FlatChainStoreConfig

Source§

fn clone(&self) -> FlatChainStoreConfig

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FromRef<T> for T
where T: Clone,

§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more