fn block(block_index: BlockHeight) -> Option<Result<EncodedBlock, CanisterId>> {
    let state = LEDGER.read().unwrap();
    if block_index < state.blockchain.num_archived_blocks() {
        // The block we are looking for better be in the archive because it has
        // a height smaller than the number of blocks we've archived so far
        let result = state
            .find_block_in_archive(block_index)
            .expect("block not found in the archive");
        Some(Err(result))
    // Or the block may be in the ledger, or the block may not exist
    } else {
        print(format!(
            "[ledger] Checking the ledger for block [{}]",
            block_index
        ));
        match state.blockchain.get(block_index).cloned() {
            // Block in the ledger
            Some(block) => Some(Ok(block)),
            // Not in the ledger and not in the archive. Thus, does not exist
            None => None,
        }
    }
}
// This is going away and being replaced by getblocks
This is going away and being replaced by getblocks
This is going away and being replaced by getblocks
fn block(block_index: BlockHeight) -> Option<Result<EncodedBlock, CanisterId>> {
    let state = LEDGER.read().unwrap();
    if block_index < state.blockchain.num_archived_blocks() {
        // The block we are looking for better be in the archive because it has
        // a height smaller than the number of blocks we've archived so far
        let result = state
            .find_block_in_archive(block_index)
            .expect("block not found in the archive");
        Some(Err(result))
    // Or the block may be in the ledger, or the block may not exist
    } else {
        print(format!(
            "[ledger] Checking the ledger for block [{}]",
            block_index
        ));
        match state.blockchain.get(block_index).cloned() {
            // Block in the ledger
            Some(block) => Some(Ok(block)),
            // Not in the ledger and not in the archive. Thus, does not exist
            None => None,
        }
    }
}
fn block ( block_index : BlockHeight ) -> Option < Result < EncodedBlock , CanisterId > > { let state = LEDGER . read ( ) . unwrap ( ) ; if block_index < state . blockchain . num_archived_blocks ( ) { // The block we are looking for better be in the archive because it has // a height smaller than the number of blocks we've archived so far let result = state . find_block_in_archive ( block_index ) . expect ( " " ) ; Some ( Err ( result ) ) // Or the block may be in the ledger, or the block may not exist } else { print ( format ! ( " " block_index ) ) ; match state . blockchain . get ( block_index ) . cloned ( ) { // Block in the ledger Some ( block ) => Some ( Ok ( block ) ) , // Not in the ledger and not in the archive. Thus, does not exist None => None , } } }
This is going away and being replaced by getblocks
This is going away and being replaced by getblocks
block_index
BlockHeight
block_index
BlockHeight