From 709274aa30cdfb9230f1db5871c7143acd1d5f1d Mon Sep 17 00:00:00 2001 From: Robert Habermeier Date: Tue, 28 Aug 2018 14:13:02 +0200 Subject: [PATCH] log inconsistent bitfield state --- Cargo.toml | 1 + src/bitfield.rs | 6 ++++-- src/lib.rs | 2 ++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index fac8ec76..9503754e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,3 +6,4 @@ authors = ["Parity Technologies "] [dependencies] parking_lot = "0.4" +log = "0.4" diff --git a/src/bitfield.rs b/src/bitfield.rs index 8f635e64..a3fe7b5d 100644 --- a/src/bitfield.rs +++ b/src/bitfield.rs @@ -175,11 +175,13 @@ impl LiveBitfield { let word_off = bit_idx / 64; let bit_off = bit_idx % 64; - // TODO: if this isn't `Some`, something has gone really wrong. - // log it? + // If this isn't `Some`, something has gone really wrong. if let Some(word) = self.bits.get_mut(word_off) { // set bit starting from left. *word |= 1 << (63 - bit_off) + } else { + warn!(target: "afg", "Could not set bit {}. Bitfield was meant to have 2 bits for each of {} validators.", + bit_idx, self.shared.n_validators); } } diff --git a/src/lib.rs b/src/lib.rs index 73bfb05c..a8fafef2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -19,6 +19,8 @@ //! https://hackmd.io/iA4XazxWRJ21LqMxwPSEZg?view extern crate parking_lot; +#[macro_use] +extern crate log; pub mod bitfield; pub mod round;