Struct FsBlock

Source
pub struct FsBlock {
    pub file: Arc<Mutex<File>>,
    pub start: usize,
    pub end: usize,
    pub hash: BlockHash,
    pub prev: BlockHash,
    pub next: Vec<BlockHash>,
    pub serialization_version: u8,
    /* private fields */
}
Expand description

Before reorder we keep only the position of the block in the file system and data relative to the block hash, the previous hash and the following hash (populated during reorder phase) We will need to read the block from disk again, but by doing so we will avoid using too much memory in the OutOfOrderBlocks map.

Fields§

§file: Arc<Mutex<File>>

the file the block identified by hash is stored in. Multiple blocks are stored in the and we don’t want to open/close the file many times for performance reasons so it’s shared. It’s a Mutex to allow to be sent between threads but only one thread (reorder) mutably access to it so there is no contention. (Arc alone isn’t enough cause it can’t be mutated, RefCell can be mutated but not sent between threads)

§start: usize

The start position in bytes in the file at which the block identified by hash

§end: usize

The end position in bytes in the file at which the block identified by hash

§hash: BlockHash

The hash identifying this block, output of block.header.block_hash()

§prev: BlockHash

The hash of the block previous to this one, block.header.prev_blockhash

§next: Vec<BlockHash>

The hash of the blocks following this one. It is populated during the reorder phase, it can be more than one because of reorgs.

§serialization_version: u8

The serialization format to use when trasformed to BlockExtra (0 or 1)

Trait Implementations§

Source§

impl Debug for FsBlock

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl TryFrom<FsBlock> for BlockExtra

Source§

type Error = String

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

fn try_from(fs_block: FsBlock) -> Result<Self, Self::Error>

Performs the conversion.

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> Same for T

Source§

type Output = T

Should always be Self
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.