pub fn median_time_past(&self, height: Height) -> BlockTime {
        assert!(height != 0, "height must be > 0");

        let mut times = [0 as BlockTime; time::MEDIAN_TIME_SPAN as usize];

        let start = height.saturating_sub(time::MEDIAN_TIME_SPAN);
        let end = height;

        for (i, blk) in self.range(start..end).enumerate() {
            times[i] = blk.time;
        }

        // Gracefully handle the case where `height` < `MEDIUM_TIME_SPAN`.
        let available = &mut times[0..(end - start) as usize];

        available.sort_unstable();
        available[available.len() / 2]
    }
/// Get the median time past for the blocks leading up to the given height.
///
/// # Errors
///
/// Panics if height is `0`.
///
Get the median time past for the blocks leading up to the given height.
Get the median time past for the blocks leading up to the given height .
pub fn median_time_past(&self, height: Height) -> BlockTime {
        assert!(height != 0, "height must be > 0");
        let mut times = [0 as BlockTime; time::MEDIAN_TIME_SPAN as usize];
        let start = height.saturating_sub(time::MEDIAN_TIME_SPAN);
        let end = height;
        for (i, blk) in self.range(start..end).enumerate() {
            times[i] = blk.time;
        }
        // Gracefully handle the case where `height` < `MEDIUM_TIME_SPAN`.
        let available = &mut times[0..(end - start) as usize];
        available.sort_unstable();
        available[available.len() / 2]
    }
pub fn median_time_past ( & self , height : Height ) -> BlockTime { assert ! ( height 0 " " ) ; let mut times = [ 0 as BlockTime ; time :: MEDIAN_TIME_SPAN as usize ] ; let start = height . saturating_sub ( time :: MEDIAN_TIME_SPAN ) ; let end = height ; for ( i , blk ) in self . range ( start .. end ) . enumerate ( ) { times [ i ] = blk . time ; } // Gracefully handle the case where `height` < `MEDIUM_TIME_SPAN`. let available = & mut times [ 0 .. ( end - start ) as usize ] ; available . sort_unstable ( ) ; available [ available . len ( ) / 2 ] }
Get the median time past for the blocks leading up to the given height.
Get the median time past for the blocks leading up to the given height .
&self
height
Height
errors
Panics if height is `0`.
Panics if height is ` 0 ` .