Do not log_debug when we receive duplicate gossip messages
[rust-lightning] / lightning / src / ln / msgs.rs
index 6f4795c75e8a7413d6ce18fbd1021dfbf5b99fec..c45e2277fb8db5a307a2b0c13fb546d97d62ec74 100644 (file)
@@ -32,11 +32,13 @@ use bitcoin::hash_types::{Txid, BlockHash};
 
 use ln::features::{ChannelFeatures, InitFeatures, NodeFeatures};
 
+use prelude::*;
 use core::{cmp, fmt};
 use core::fmt::Debug;
 use std::io::Read;
 
 use util::events::MessageSendEventsProvider;
+use util::logger;
 use util::ser::{Readable, Writeable, Writer, FixedLengthReader, HighZeroBytesDroppedVarInt};
 
 use ln::{PaymentPreimage, PaymentHash, PaymentSecret};
@@ -45,7 +47,7 @@ use ln::{PaymentPreimage, PaymentHash, PaymentSecret};
 pub(crate) const MAX_VALUE_MSAT: u64 = 21_000_000_0000_0000_000;
 
 /// An error in decoding a message or struct.
-#[derive(Clone, Debug)]
+#[derive(Clone, Debug, PartialEq)]
 pub enum DecodeError {
        /// A version byte specified something we don't know how to handle.
        /// Includes unknown realm byte in an OnionHopData packet
@@ -687,7 +689,11 @@ pub enum ErrorAction {
                msg: Option<ErrorMessage>
        },
        /// The peer did something harmless that we weren't able to process, just log and ignore
+       // New code should *not* use this. New code must use IgnoreAndLog, below!
        IgnoreError,
+       /// The peer did something harmless that we weren't able to meaningfully process.
+       /// If the error is logged, log it at the given level.
+       IgnoreAndLog(logger::Level),
        /// The peer did something incorrect. Tell them.
        SendErrorMessage {
                /// The message to send.
@@ -878,6 +884,7 @@ pub trait RoutingMessageHandler : MessageSendEventsProvider {
 }
 
 mod fuzzy_internal_msgs {
+       use prelude::*;
        use ln::PaymentSecret;
 
        // These types aren't intended to be pub, but are exposed for direct fuzzing (as we deserialize
@@ -1852,6 +1859,7 @@ mod tests {
        use bitcoin::secp256k1::key::{PublicKey,SecretKey};
        use bitcoin::secp256k1::{Secp256k1, Message};
 
+       use prelude::*;
        use std::io::Cursor;
 
        #[test]