parse.rs

Overview

This file provides functionality for reading and serializing blockchain-related data structures, specifically focusing on zero state accounts and messages within a shard/thread context. It includes implementations for extracting detailed information from accounts and messages, serializing them into a transportable format, and interacting with message storage abstractions. The main focus is on the ZeroState structure, which encapsulates methods for accessing shard state data such as accounts and messages.

Key capabilities include:

This file interacts closely with core blockchain entities such as ThreadIdentifier, MessageIdentifier, WrappedMessage, and state-related types like StateInit. It also relies on message serialization and Base64 encoding utilities to prepare messages for external use or transport.


Structs and Traits

DummyMessageStorage

A stub implementation of the DurableStorageRead trait for messages.

This dummy storage is used internally when iterating over messages in the zero state, as actual persistent storage is not needed or not yet implemented.


ZeroStateMessage

A serializable representation of a blockchain message in zero state.

This struct provides a high-level view of message data suitable for export or further processing.


ZeroStateAccount

A serializable representation of a blockchain account in zero state.

Represents accounts in a simplified form, focusing on identifiers, code, and balance.


impl ZeroState

The core implementation providing methods for reading accounts and messages from a zero state.

read_all_accounts

pub fn read_all_accounts(
    &mut self,
    thread_identifier: &ThreadIdentifier,
) -> anyhow::Result<Vec<ZeroStateAccount>>

Example

let accounts = zero_state.read_all_accounts(&thread_id)?;
for account in accounts {
    println!("Account: {}", account.address);
}

read_all_messages

pub fn read_all_messages(
    &mut self,
    thread_identifier: &ThreadIdentifier,
) -> anyhow::Result<Vec<ZeroStateMessage>>

Example

let messages = zero_state.read_all_messages(&thread_id)?;
for msg in messages {
    println!("Message id: {}", msg.id);
}

Important Implementation Details


Interactions with Other Modules

These components collaborate to extract, serialize, and present zero state blockchain data in a structured form.


Mermaid Diagram: File Structure and Main Functions Flow

flowchart TD
ZeroState["ZeroState"]
DummyStorage["DummyMessageStorage"]
ReadAccounts["read_all_accounts()"]
ReadMessages["read_all_messages()"]
MsgIterator["AccountMessagesIterator"]
State["Shard State"]
MsgQueue["Messages Queue"]
MsgStorage["DurableStorageRead Trait"]
ZeroState --> ReadAccounts
ZeroState --> ReadMessages
ReadMessages --> MsgQueue
MsgQueue --> MsgIterator
MsgIterator --> DummyStorage
DummyStorage --> MsgStorage
ReadAccounts --> State
ReadMessages --> State

This diagram shows ZeroState as the central struct, with two main methods: read_all_accounts and read_all_messages. read_all_messages interacts with message queues and an iterator that depends on a message storage backend, represented here by DummyMessageStorage. Both methods rely on the shard state accessed through ZeroState.