PendingStore is used to store the pending blocks and txs, and handle the reorg
- Resource
PendingBlock
- Resource
PendingStore
- Struct
InprocessBlock
- Struct
ReorgEvent
- Struct
PendingTxs
- Constants
- Function
genesis_init
- Function
add_pending_block
- Function
process_pending_tx
- Function
finish_pending_tx
- Function
finish_pending_block
- Function
inprocess_block_flotsams_mut
- Function
inprocess_block_flotsams
- Function
inprocess_block_tx
- Function
inprocess_block_header
- Function
inprocess_block_height
- Function
get_ready_pending_txs
- Function
get_best_block
- Function
get_reorg_block_count
- Function
update_reorg_block_count_for_local
use 0x1::option;
use 0x1::vector;
use 0x2::event;
use 0x2::object;
use 0x2::simple_map;
use 0x3::chain_id;
use 0x4::ord;
use 0x4::types;
struct PendingBlock has key
struct PendingStore has key
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 InprocessBlock
struct ReorgEvent has copy, drop
struct PendingTxs has copy, drop, store
const BLOCK_FLOTSAM_KEY: vector<u8> = [98, 108, 111, 99, 107, 95, 102, 108, 111, 116, 115, 97, 109];
const ErrorBlockAlreadyProcessed: u64 = 1;
const ErrorNeedToWaitMoreBlocks: u64 = 5;
const ErrorPendingBlockNotFinished: u64 = 6;
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];
public(friend) fun genesis_init(reorg_block_count: u64)
public(friend) fun add_pending_block(block_height: u64, block_hash: address, block: types::Block)
public(friend) fun process_pending_tx(block_hash: address, txid: address): pending_block::InprocessBlock
public(friend) fun finish_pending_tx(inprocess_block: pending_block::InprocessBlock)
public(friend) fun finish_pending_block(inprocess_block: pending_block::InprocessBlock): types::Header
public(friend) fun inprocess_block_flotsams_mut(inprocess_block: &mut pending_block::InprocessBlock): &mut vector<ord::Flotsam>
public(friend) fun inprocess_block_flotsams(inprocess_block: &pending_block::InprocessBlock): vector<ord::Flotsam>
public(friend) fun inprocess_block_tx(inprocess_block: &pending_block::InprocessBlock): &types::Transaction
public(friend) fun inprocess_block_header(inprocess_block: &pending_block::InprocessBlock): &types::Header
public(friend) fun inprocess_block_height(inprocess_block: &pending_block::InprocessBlock): u64
Get the pending txs which are ready to be processed
public fun get_ready_pending_txs(): option::Option<pending_block::PendingTxs>
public fun get_best_block(): option::Option<types::BlockHeightHash>
public fun get_reorg_block_count(): u64
Update the reorg_block_count
config for local env to testing
public entry fun update_reorg_block_count_for_local(count: u64)