Skip to main content

BlockChanges

Struct BlockChanges 

Source
pub struct BlockChanges {
    pub extractor: String,
    pub chain: Chain,
    pub block: Block,
    pub finalized_block_height: u64,
    pub revert: bool,
    pub new_tokens: HashMap<Address, Token>,
    pub txs_with_update: Vec<TxWithChanges>,
    pub block_contract_changes: Vec<TxWithContractChanges>,
    pub trace_results: Vec<TracedEntryPoint>,
    pub partial_block_index: Option<u32>,
}

Fields§

§extractor: String§chain: Chain§block: Block§finalized_block_height: u64§revert: bool§new_tokens: HashMap<Address, Token>§txs_with_update: Vec<TxWithChanges>

Vec of updates at this block, aggregated by tx and sorted by tx index in ascending order

§block_contract_changes: Vec<TxWithContractChanges>§trace_results: Vec<TracedEntryPoint>

Required here so that it is part of the reorg buffer and thus inserted into storage once finalized. Populated by the DynamicContractIndexer

§partial_block_index: Option<u32>

The index of the partial block. None if it’s a full block.

Implementations§

Source§

impl BlockChanges

Source

pub fn new( extractor: String, chain: Chain, block: Block, finalized_block_height: u64, revert: bool, txs_with_update: Vec<TxWithChanges>, block_contract_changes: Vec<TxWithContractChanges>, ) -> Self

Source

pub fn into_aggregated( self, db_committed_block_height: Option<u64>, ) -> Result<BlockAggregatedChanges, MergeError>

Aggregates component and account updates.

This function aggregates all protocol updates into a BlockAggregatedChanges object. This new object should have all individual changes merged into only one final/compacted change per component and account. This means there is only one state delta and component balance per component, and one account delta and account balance per account. DCI trace results are also aggregated into a result per entry point.

Note - all non-protocol specific data in the BlockChanges object are lost during aggregation. This means block_storage_changes is dropped.

§Errors

This returns a MergeError if there was a problem during merge.

Source

pub fn protocol_components(&self) -> Vec<ProtocolComponent>

Source

pub fn is_partial_block(&self) -> bool

Returns true if the block is a partial block.

Source

pub fn set_partial_block_index(&mut self, index: Option<u32>)

Sets the partial block index.

Source

pub fn normalize_block_hash(&mut self)

Sets every transaction’s block_hash in txs_with_update and block_contract_changes to this block’s hash. Used after merging partials so all txs refer to the same block (e.g. the final block hash).

Source

pub fn merge_partial(self, other: Self) -> Result<Self, MergeError>

Merges another partial block into this one, preserving later changes.

The partial block with the higher index represents later changes and takes precedence. Merges new_tokens, txs_with_update (sorted by index), block_contract_changes, and trace_results. When both blocks have the same token address, the token from the block with the higher partial index is kept.

Works regardless of merge order: partial_0.merge_partial(partial_1) and partial_1.merge_partial(partial_0) produce equivalent results.

§Errors
  • Non-partial block: Either block is not marked as partial
  • Extractor mismatch: Blocks from different extractors
  • Chain mismatch: Blocks from different chains
  • Block mismatch: Different block numbers (hash may differ for temp vs final partial)
  • Revert mismatch: Different revert status

Trait Implementations§

Source§

impl BlockScoped for BlockChanges

Source§

fn block(&self) -> Block

Source§

impl Clone for BlockChanges

Source§

fn clone(&self) -> BlockChanges

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for BlockChanges

Source§

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

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

impl DeepSizeOf for BlockChanges

Source§

fn deep_size_of_children(&self, context: &mut Context) -> usize

Returns an estimation of the heap-managed storage of this object. This does not include the size of the object itself. Read more
Source§

fn deep_size_of(&self) -> usize

Returns an estimation of a total size of memory owned by the object, including heap-managed storage. Read more
Source§

impl Default for BlockChanges

Source§

fn default() -> BlockChanges

Returns the “default value” for a type. Read more
Source§

impl PartialEq for BlockChanges

Source§

fn eq(&self, other: &BlockChanges) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for BlockChanges

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, dest: *mut u8)

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

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

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

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

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
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

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

fn with_current_subscriber(self) -> WithDispatch<Self>

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