---
# System prepended metadata

title: Find outages in public blockchain history

---

# Find outages in public blockchain history

Your coding challenge involves identifying the most reliable Ethereum testnet based on a specific criterion: **consistent block production at a fixed interval with no gaps**. In this context, a normal block is produced every 1 second (blocks are never produced more often than that), and any delay beyond (>) 2 seconds is considered a gap that needs to be recorded.


To accomplish this, you have access to two API methods:

* get_block_timestamp(height): This method provides the timestamp of a block at a given height, measured in milliseconds. Note that that this method is slow and resource-intensive.

* get_current_block_height(): This method offers the height of the latest produced block - you only need to invoke it once in the beginning to get the current block height.
 

```rust=
    


let totalBlocks = get_current_block_height()
let currentTimestamp = get_block_timestamp(currentBlock)
let startTimestamp = get_block_timestamp(0)
let diff = currentTimestamp - startTimestamp

let average = diff/totalBlocks

// [1.9, 1.9, 1.9] < 6
// [1, 1, 2.5] 

let noFaultyBlocks = 0


let num = getNFaulty(0, totalBlocks)



function getNFaulty(start: number, end: number) {

    if (start > end) throw Error() 
    
    let startTimestamp = get_block_timestamp(start)
    let endTimestamp = get_block_timestamp(end)
    
    if (end - start == 1 && endTimestamp - startTimestamp > 2)  return 1
    
    if (endTimestamp - startTimestamp < end - start + 1) {
        return 0
    } else {
        
        let mid = Math.floor((end + start) / 2)
        
        return getNFaulty(start, mid) + getNFaulty(mid , end)
    }
}

```


