X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning-rapid-gossip-sync%2Fsrc%2Fprocessing.rs;h=b3fae0ffd8bea8e19822c5a2cf9bc19d3fe33939;hb=3a9fe209e104e048921ad50be77a80b18a98b45c;hp=fca318a5fa5f8cfac735ff8d3880819e8b6d93a0;hpb=91536edb0dcd4d662a8945892fc5046b0265a74d;p=rust-lightning diff --git a/lightning-rapid-gossip-sync/src/processing.rs b/lightning-rapid-gossip-sync/src/processing.rs index fca318a5..b3fae0ff 100644 --- a/lightning-rapid-gossip-sync/src/processing.rs +++ b/lightning-rapid-gossip-sync/src/processing.rs @@ -2,7 +2,7 @@ use core::cmp::max; use core::ops::Deref; use core::sync::atomic::Ordering; -use bitcoin::BlockHash; +use bitcoin::blockdata::constants::ChainHash; use bitcoin::secp256k1::PublicKey; use lightning::ln::msgs::{ @@ -14,13 +14,12 @@ use lightning::{log_debug, log_warn, log_trace, log_given_level, log_gossip}; use lightning::util::ser::{BigSize, Readable}; use lightning::io; -use crate::error::GraphSyncError; -use crate::RapidGossipSync; +use crate::{GraphSyncError, RapidGossipSync}; #[cfg(all(feature = "std", not(test)))] use std::time::{SystemTime, UNIX_EPOCH}; -#[cfg(not(feature = "std"))] +#[cfg(all(not(feature = "std"), not(test)))] use alloc::{vec::Vec, borrow::ToOwned}; /// The purpose of this prefix is to identify the serialization format, should other rapid gossip @@ -67,9 +66,9 @@ impl>, L: Deref> RapidGossipSync where L return Err(DecodeError::UnknownVersion.into()); } - let chain_hash: BlockHash = Readable::read(read_cursor)?; - let ng_genesis_hash = self.network_graph.get_genesis_hash(); - if chain_hash != ng_genesis_hash { + let chain_hash: ChainHash = Readable::read(read_cursor)?; + let ng_chain_hash = self.network_graph.get_chain_hash(); + if chain_hash != ng_chain_hash { return Err( LightningError { err: "Rapid Gossip Sync data's chain hash does not match the network graph's".to_owned(), @@ -269,9 +268,8 @@ mod tests { use lightning::routing::gossip::NetworkGraph; use lightning::util::test_utils::TestLogger; - use crate::error::GraphSyncError; use crate::processing::STALE_RGS_UPDATE_AGE_LIMIT_SECS; - use crate::RapidGossipSync; + use crate::{GraphSyncError, RapidGossipSync}; const VALID_RGS_BINARY: [u8; 300] = [ 76, 68, 75, 1, 111, 226, 140, 10, 182, 241, 179, 114, 193, 166, 162, 70, 174, 99, 247,