Merge branch 'master' into auth-round
This commit is contained in:
@@ -32,7 +32,8 @@ use node_table::NodeId;
|
||||
use stats::NetworkStats;
|
||||
use time;
|
||||
|
||||
const PING_TIMEOUT_SEC: u64 = 65;
|
||||
// Timeout must be less than (interval - 1).
|
||||
const PING_TIMEOUT_SEC: u64 = 15;
|
||||
const PING_INTERVAL_SEC: u64 = 30;
|
||||
|
||||
/// Peer session over encrypted connection.
|
||||
|
||||
@@ -30,7 +30,7 @@ pub struct Histogram {
|
||||
impl Histogram {
|
||||
/// Histogram if a sorted corpus is at least fills the buckets.
|
||||
pub fn new(corpus: &[U256], bucket_number: usize) -> Option<Histogram> {
|
||||
if corpus.len() < bucket_number { return None; }
|
||||
if corpus.len() <= bucket_number { return None; }
|
||||
let corpus_end = corpus.last().expect("there are at least bucket_number elements; qed").clone();
|
||||
// If there are extremely few transactions, go from zero.
|
||||
let corpus_start = corpus.first().expect("there are at least bucket_number elements; qed").clone();
|
||||
@@ -67,4 +67,9 @@ mod tests {
|
||||
|
||||
assert!(Histogram::new(&vec_into![1, 2], 5).is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn should_not_panic_when_asking_for_bucket_too_big() {
|
||||
assert!(Histogram::new(&vec_into![1, 2], 2).is_none());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user