@@ -31,15 +31,15 @@ const MAX_INITIAL_NODE_ID_VECTOR_CAPACITY: u32 = 50_000;
31
31
pub fn update_network_graph (
32
32
network_graph : & network_graph:: NetworkGraph ,
33
33
update_data : & [ u8 ] ,
34
- ) -> Result < ( ) , GraphSyncError > {
34
+ ) -> Result < ( u32 ) , GraphSyncError > {
35
35
let mut read_cursor = io:: Cursor :: new ( update_data) ;
36
36
update_network_graph_from_byte_stream ( & network_graph, & mut read_cursor)
37
37
}
38
38
39
39
pub ( crate ) fn update_network_graph_from_byte_stream < R : Read > (
40
40
network_graph : & network_graph:: NetworkGraph ,
41
41
mut read_cursor : & mut R ,
42
- ) -> Result < ( ) , GraphSyncError > {
42
+ ) -> Result < ( u32 ) , GraphSyncError > {
43
43
let mut prefix = [ 0u8 ; 4 ] ;
44
44
read_cursor. read_exact ( & mut prefix) ?;
45
45
@@ -52,6 +52,8 @@ pub(crate) fn update_network_graph_from_byte_stream<R: Read>(
52
52
53
53
let chain_hash: BlockHash = Readable :: read ( read_cursor) ?;
54
54
let latest_seen_timestamp: u32 = Readable :: read ( read_cursor) ?;
55
+ // backdate the applied timestamp by a week
56
+ let backdated_timestamp = latest_seen_timestamp - 24 * 3600 * 7 ;
55
57
56
58
let node_id_count: u32 = Readable :: read ( read_cursor) ?;
57
59
let mut node_ids: Vec < PublicKey > = Vec :: with_capacity ( std:: cmp:: min (
@@ -85,7 +87,7 @@ pub(crate) fn update_network_graph_from_byte_stream<R: Read>(
85
87
86
88
let announcement_result = network_graph. add_channel_from_partial_announcement (
87
89
short_channel_id,
88
- latest_seen_timestamp as u64 ,
90
+ backdated_timestamp as u64 ,
89
91
features,
90
92
node_id_1,
91
93
node_id_2,
@@ -103,7 +105,7 @@ pub(crate) fn update_network_graph_from_byte_stream<R: Read>(
103
105
104
106
let update_count: u32 = Readable :: read ( read_cursor) ?;
105
107
if update_count == 0 {
106
- return Ok ( ( ) ) ;
108
+ return Ok ( ( latest_seen_timestamp ) ) ;
107
109
}
108
110
109
111
// obtain default values for non-incremental updates
@@ -135,7 +137,7 @@ pub(crate) fn update_network_graph_from_byte_stream<R: Read>(
135
137
UnsignedChannelUpdate {
136
138
chain_hash,
137
139
short_channel_id,
138
- timestamp : latest_seen_timestamp ,
140
+ timestamp : backdated_timestamp ,
139
141
flags : standard_channel_flags,
140
142
cltv_expiry_delta : default_cltv_expiry_delta,
141
143
htlc_minimum_msat : default_htlc_minimum_msat,
@@ -172,7 +174,7 @@ pub(crate) fn update_network_graph_from_byte_stream<R: Read>(
172
174
UnsignedChannelUpdate {
173
175
chain_hash,
174
176
short_channel_id,
175
- timestamp : latest_seen_timestamp ,
177
+ timestamp : backdated_timestamp ,
176
178
flags : standard_channel_flags,
177
179
cltv_expiry_delta : directional_info. cltv_expiry_delta ,
178
180
htlc_minimum_msat : directional_info. htlc_minimum_msat ,
@@ -216,7 +218,7 @@ pub(crate) fn update_network_graph_from_byte_stream<R: Read>(
216
218
network_graph. update_channel_unsigned ( & synthetic_update) ?;
217
219
}
218
220
219
- Ok ( ( ) )
221
+ Ok ( ( latest_seen_timestamp ) )
220
222
}
221
223
222
224
#[ cfg( test) ]
0 commit comments