gossipd: bias lower bit of timestamp to ensure alternation.

This is useful for various "partial timestamp" forms of propagation
in future, esp. minisketch.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2019-09-16 20:13:59 +09:30
parent 21a6d502db
commit 06afb408d8
1 changed files with 16 additions and 1 deletions

View File

@ -147,6 +147,12 @@ static void update_own_node_announcement(struct daemon *daemon)
/* Discard existing timer. */
daemon->node_announce_timer = tal_free(daemon->node_announce_timer);
/* If we ever use set-based propagation, ensuring the toggle the lower
* bit in consecutive timestamps makes it more robust. */
if (self && self->bcast.index
&& (timestamp & 1) == (self->bcast.timestamp & 1))
timestamp++;
/* Make unsigned announcement. */
nannounce = create_node_announcement(tmpctx, daemon, NULL, timestamp);
@ -283,6 +289,16 @@ static void update_local_channel(struct local_cupdate *lc /* frees! */)
*/
message_flags = 0 | ROUTING_OPT_HTLC_MAX_MSAT;
/* Convenience variable. */
hc = &chan->half[direction];
/* If we ever use set-based propagation, ensuring the toggle
* the lower bit in consecutive timestamps makes it more
* robust. */
if (is_halfchan_defined(hc)
&& (timestamp & 1) == (hc->bcast.timestamp & 1))
timestamp++;
/* We create an update with a dummy signature, and hand to hsmd to get
* it signed. */
update = towire_channel_update_option_channel_htlc_max(tmpctx, &dummy_sig,
@ -296,7 +312,6 @@ static void update_local_channel(struct local_cupdate *lc /* frees! */)
lc->fee_proportional_millionths,
lc->htlc_maximum);
hc = &chan->half[direction];
if (is_halfchan_defined(hc)) {
/* Suppress duplicates. */
if (!lc->even_if_identical