Skip to content

Latest commit

 

History

History
338 lines (141 loc) · 10.2 KB

pending_block.md

File metadata and controls

338 lines (141 loc) · 10.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 BLOCK_FLOTSAM_KEY: vector<u8> = [98, 108, 111, 99, 107, 95, 102, 108, 111, 116, 115, 97, 109];

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)

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_flotsams_mut

public(friend) fun inprocess_block_flotsams_mut(inprocess_block: &mut pending_block::InprocessBlock): &mut vector<ord::Flotsam>

Function inprocess_block_flotsams

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_for_local

Update the reorg_block_count config for local env to testing

public entry fun update_reorg_block_count_for_local(count: u64)