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.
- Block
Header - A masterchain block’s header, read for the fields a proof chain rests on.
- Block
IdExt - The block identity and proof-chain types
verify_chainreads, 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.
- McState
Extra - The masterchain-only part of a masterchain state.
- Partial
Block Proof - The block identity and proof-chain types
verify_chainreads, re-exported from ton-net-tl so a caller need not name that crate to check a chain. TheliteServer.partialBlockProofresponse: as much of a proof chain as the server chose to send at once. - Shard
Account Entry - What a shard’s accounts dictionary holds for one account.
- Shard
Descr - What a masterchain state records about one shard’s latest block.
- Shard
State - A shard state, walked only as far as reading one account needs.
Enums§
- Account
Status - An account’s status, with the contents that only some statuses have.
- Block
Error - A failure decoding a TON block or account structure from cells.
- Block
Link - The block identity and proof-chain types
verify_chainreads, re-exported from ton-net-tl so a caller need not name that crate to check a chain. AliteServer.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.