Skip to main content

Crate ton_net_block

Crate ton_net_block 

Source
Expand description

TON block and account structures, decoded from cells, for ton-net.

This crate turns the cells a liteserver returns into values a reader can use. It reads the account structure into an Account, walks the fragments of a block and a shard state that an account read and its proof depend on, and reads a block’s BlockHeader and the ValidatorSet a key block names.

It decodes only what a read or a proof needs. A shard state carries message queues and libraries, and a block carries its whole transaction set; none of that is read here.

§Trust

Decoding and checking are separate here, and the types say which is which. An Account from Account::decode is bytes a server sent, believed because the server said so. The same type from proof::verify_account was checked against a block hash the caller trusts. Nothing about the value records the difference, so the caller keeps track of which call produced it; the facade above this crate is where that distinction is carried in the type.

This is an internal crate of the ton-net client.

§Examples

use ton_net_block::{Account, AccountStatus};

// A liteserver reports an address nothing has been stored under as empty bytes.
let account = Account::decode(&[])?;
assert_eq!(account.status, AccountStatus::Nonexistent);
assert_eq!(account.balance.nanotons(), 0);

Re-exports§

pub use chain::verify_chain;
pub use chain::ProvenBlock;
pub use proof::verify_account;
pub use proof::AccountRead;
pub use validators::Validator;
pub use validators::ValidatorSet;

Modules§

chain
Checking a block proof chain, one link at a time.
proof
Checking an account read against a block hash the caller trusts.
signature
Ed25519 verification, and the two messages a TON validator signature covers.
validators
The validator set a key block names, read from its configuration.

Structs§

Account
An account as it stands at one block.
Block
A block, walked for its header, its configuration, and the state it leaves behind.
BlockHeader
A masterchain block’s header, read for the fields a proof chain rests on.
BlockIdExt
The block identity and proof-chain types verify_chain reads, re-exported from ton-net-tl so a caller need not name that crate to check a chain. A full block identifier: the block’s workchain and shard, its sequence number, and its root and file hashes.
Coins
An amount of TON, held in nanotons.
McStateExtra
The masterchain-only part of a masterchain state.
PartialBlockProof
The block identity and proof-chain types verify_chain reads, re-exported from ton-net-tl so a caller need not name that crate to check a chain. The liteServer.partialBlockProof response: as much of a proof chain as the server chose to send at once.
ShardAccountEntry
What a shard’s accounts dictionary holds for one account.
ShardDescr
What a masterchain state records about one shard’s latest block.
ShardState
A shard state, walked only as far as reading one account needs.

Enums§

AccountStatus
An account’s status, with the contents that only some statuses have.
BlockError
A failure decoding a TON block or account structure from cells.
BlockLink
The block identity and proof-chain types verify_chain reads, re-exported from ton-net-tl so a caller need not name that crate to check a chain. A liteServer.BlockLink: one step of a block proof chain.
Lookup
How a dictionary lookup ended, re-exported from ton-net-cell because this crate’s own reads answer with it. How a lookup ended.