@ -386,8 +386,6 @@ static void init_half_chan(struct routing_state *rstate,
{
{
struct half_chan * c = & chan - > half [ channel_idx ] ;
struct half_chan * c = & chan - > half [ channel_idx ] ;
c - > channel_update = NULL ;
/* Set the channel direction */
/* Set the channel direction */
c - > channel_flags = channel_idx ;
c - > channel_flags = channel_idx ;
// TODO: wireup message_flags
// TODO: wireup message_flags
@ -971,11 +969,17 @@ bool routing_add_channel_announcement(struct routing_state *rstate,
* add fresh ones . But if we ' re loading off disk right now , we can ' t
* add fresh ones . But if we ' re loading off disk right now , we can ' t
* do that . */
* do that . */
if ( chan & & index = = 0 ) {
if ( chan & & index = = 0 ) {
/* Steal any private updates */
/* Reload any private updates */
if ( chan - > half [ 0 ] . bcast . index )
private_updates [ 0 ]
private_updates [ 0 ]
= tal_steal ( NULL , chan - > half [ 0 ] . channel_update ) ;
= gossip_store_get ( NULL ,
rstate - > broadcasts - > gs ,
chan - > half [ 0 ] . bcast . index ) ;
if ( chan - > half [ 1 ] . bcast . index )
private_updates [ 1 ]
private_updates [ 1 ]
= tal_steal ( NULL , chan - > half [ 1 ] . channel_update ) ;
= gossip_store_get ( NULL ,
rstate - > broadcasts - > gs ,
chan - > half [ 1 ] . bcast . index ) ;
}
}
/* Pretend it didn't exist, for the moment. */
/* Pretend it didn't exist, for the moment. */
@ -1330,6 +1334,10 @@ bool routing_add_channel_update(struct routing_state *rstate,
if ( taken ( update ) )
if ( taken ( update ) )
tal_steal ( tmpctx , update ) ;
tal_steal ( tmpctx , update ) ;
/* In case it's free in a failure path */
if ( taken ( update ) )
tal_steal ( tmpctx , update ) ;
if ( ! fromwire_channel_update ( update , & signature , & chain_hash ,
if ( ! fromwire_channel_update ( update , & signature , & chain_hash ,
& short_channel_id , & timestamp ,
& short_channel_id , & timestamp ,
& message_flags , & channel_flags ,
& message_flags , & channel_flags ,
@ -1388,18 +1396,6 @@ bool routing_add_channel_update(struct routing_state *rstate,
/* Discard older updates */
/* Discard older updates */
hc = & chan - > half [ direction ] ;
hc = & chan - > half [ direction ] ;
if ( is_halfchan_defined ( hc ) & & timestamp < = hc - > bcast . timestamp ) {
if ( is_halfchan_defined ( hc ) & & timestamp < = hc - > bcast . timestamp ) {
/* They're not supposed to do this! */
if ( timestamp = = hc - > bcast . timestamp
& & ! memeq ( hc - > channel_update , tal_count ( hc - > channel_update ) ,
update , tal_count ( update ) ) ) {
status_debug ( " Bad gossip repeated timestamp for %s(%u): %s then %s " ,
type_to_string ( tmpctx ,
struct short_channel_id ,
& short_channel_id ) ,
channel_flags ,
tal_hex ( tmpctx , hc - > channel_update ) ,
tal_hex ( tmpctx , update ) ) ;
}
SUPERVERBOSE ( " Ignoring outdated update. " ) ;
SUPERVERBOSE ( " Ignoring outdated update. " ) ;
/* Ignoring != failing */
/* Ignoring != failing */
return true ;
return true ;
@ -1416,15 +1412,9 @@ bool routing_add_channel_update(struct routing_state *rstate,
message_flags , channel_flags ,
message_flags , channel_flags ,
timestamp , htlc_minimum , htlc_maximum ) ;
timestamp , htlc_minimum , htlc_maximum ) ;
/* Replace any old one. */
tal_free ( chan - > half [ direction ] . channel_update ) ;
/* Safe even if was never added */
/* Safe even if was never added */
broadcast_del ( rstate - > broadcasts , & chan - > half [ direction ] . bcast ) ;
broadcast_del ( rstate - > broadcasts , & chan - > half [ direction ] . bcast ) ;
chan - > half [ direction ] . channel_update
= tal_dup_arr ( chan , u8 , update , tal_count ( update ) , 0 ) ;
/* BOLT #7:
/* BOLT #7:
* - MUST consider the ` timestamp ` of the ` channel_announcement ` to be
* - MUST consider the ` timestamp ` of the ` channel_announcement ` to be
* the ` timestamp ` of a corresponding ` channel_update ` .
* the ` timestamp ` of a corresponding ` channel_update ` .
@ -1444,7 +1434,7 @@ bool routing_add_channel_update(struct routing_state *rstate,
assert ( is_local_channel ( rstate , chan ) ) ;
assert ( is_local_channel ( rstate , chan ) ) ;
if ( ! index ) {
if ( ! index ) {
hc - > bcast . index = gossip_store_add ( rstate - > broadcasts - > gs ,
hc - > bcast . index = gossip_store_add ( rstate - > broadcasts - > gs ,
hc - > channel_ update) ;
update ) ;
} else
} else
hc - > bcast . index = index ;
hc - > bcast . index = index ;
return true ;
return true ;
@ -1454,7 +1444,7 @@ bool routing_add_channel_update(struct routing_state *rstate,
chan - > half [ direction ] . bcast . index = index ;
chan - > half [ direction ] . bcast . index = index ;
insert_broadcast ( & rstate - > broadcasts ,
insert_broadcast ( & rstate - > broadcasts ,
chan - > half [ direction ] . channel_ update,
update ,
& chan - > half [ direction ] . bcast ) ;
& chan - > half [ direction ] . bcast ) ;
if ( uc ) {
if ( uc ) {