Skip to content

Commit 650bcaa

Browse files
committed
Use the configured network rather than extracing from the net graph
When we were only generating snapshots that contained parts of the network graph, extracting the chain hash from the network graph announcements themselves was fine. However, now that we also serialize empty snapshots as a "no changes since your last sync" file, we need to initialize the chain_hash to the real network. Luckily, `config::network()` already exists to make this easy, so we simply switch to that. Fixes #92
1 parent fe228a8 commit 650bcaa

File tree

1 file changed

+1
-9
lines changed

1 file changed

+1
-9
lines changed

src/serialization.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use std::cmp::max;
22
use std::collections::HashMap;
33
use std::time::{SystemTime, UNIX_EPOCH};
44

5-
use bitcoin::Network;
65
use bitcoin::blockdata::constants::ChainHash;
76
use lightning::ln::msgs::{UnsignedChannelAnnouncement, UnsignedChannelUpdate};
87
use lightning::types::features::NodeFeatures;
@@ -130,12 +129,10 @@ pub(super) fn serialize_delta_set(channel_delta_set: DeltaSet, node_delta_set: N
130129
full_update_defaults: Default::default(),
131130
node_announcement_feature_defaults: vec![],
132131
node_mutations: Default::default(),
133-
chain_hash: ChainHash::using_genesis_block(Network::Bitcoin),
132+
chain_hash: ChainHash::using_genesis_block(config::network()),
134133
latest_seen: 0,
135134
};
136135

137-
let mut chain_hash_set = false;
138-
139136
let mut full_update_histograms = FullUpdateValueHistograms {
140137
cltv_expiry_delta: Default::default(),
141138
htlc_minimum_msat: Default::default(),
@@ -156,13 +153,8 @@ pub(super) fn serialize_delta_set(channel_delta_set: DeltaSet, node_delta_set: N
156153
let non_incremental_previous_update_threshold_timestamp = SystemTime::now().checked_sub(config::CHANNEL_REMINDER_AGE).unwrap().duration_since(UNIX_EPOCH).unwrap().as_secs() as u32;
157154

158155
for (scid, channel_delta) in channel_delta_set.into_iter() {
159-
160156
// any announcement chain hash is gonna be the same value. Just set it from the first one.
161157
let channel_announcement_delta = channel_delta.announcement.as_ref().unwrap();
162-
if !chain_hash_set {
163-
chain_hash_set = true;
164-
serialization_set.chain_hash = channel_announcement_delta.announcement.chain_hash;
165-
}
166158

167159
let current_announcement_seen = channel_announcement_delta.seen;
168160
let is_new_announcement = current_announcement_seen >= last_sync_timestamp;

0 commit comments

Comments
 (0)