Skip to content

Latest commit

 

History

History
382 lines (163 loc) · 12.2 KB

pending_block.md

File metadata and controls

382 lines (163 loc) · 12.2 KB

Module 0x4::pending_block

PendingStore is used to store the pending blocks and txs, and handle the reorg

Resource PendingBlock

struct PendingBlock has key

Resource PendingStore

struct PendingStore has key

Struct InprocessBlock

InprocessBlock is used to store the block and txs that are being processed This is a hot potato struct, can not be store and drop

Struct ReorgEvent

struct ReorgEvent has copy, drop

Struct PendingTxs

struct PendingTxs has copy, drop, store

Constants

const ErrorNeedToWaitMoreBlocks: u64 = 5;

const ErrorPendingBlockNotFound: u64 = 2;

const ErrorPendingTxNotFound: u64 = 3;

const ErrorReorgFailed: u64 = 4;

const ErrorUnsupportedChain: u64 = 7;

const TX_IDS_KEY: vector<u8> = [116, 120, 95, 105, 100, 115];

Function genesis_init

public(friend) fun genesis_init(reorg_block_count: u64)

Function add_pending_block

public(friend) fun add_pending_block(block_height: u64, block_hash: address, block: types::Block): bool

Function block_height

Function take_intermediate

The intermediate is used to store the intermediate state during the tx processing

Function add_intermediate

public(friend) fun add_intermediate<I: store>(pending_block: &mut object::Object<pending_block::PendingBlock>, intermediate: I)

Function exists_intermediate

Function process_pending_tx

public(friend) fun process_pending_tx(block_hash: address, txid: address): pending_block::InprocessBlock

Function finish_pending_tx

public(friend) fun finish_pending_tx(inprocess_block: pending_block::InprocessBlock)

Function finish_pending_block

Function inprocess_block_pending_block

Function inprocess_block_tx

Function inprocess_block_header

public(friend) fun inprocess_block_header(inprocess_block: &pending_block::InprocessBlock): &types::Header

Function inprocess_block_height

public(friend) fun inprocess_block_height(inprocess_block: &pending_block::InprocessBlock): u64

Function get_ready_pending_txs

Get the pending txs which are ready to be processed

Function get_best_block

Function get_reorg_block_count

public fun get_reorg_block_count(): u64

Function update_reorg_block_count

Update the reorg_block_count config

public entry fun update_reorg_block_count(signer: &signer, count: u64)

Function update_reorg_block_count_for_local

Update the reorg_block_count config for local env to testing

public entry fun update_reorg_block_count_for_local(count: u64)