From 28cc92cd1554e88fdadef820124d2fd8baff8171 Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Tue, 8 Aug 2017 14:18:30 +0200 Subject: [PATCH] gossip: Use bit 3 (mask 0x08) to signal initial routing sync After quite some back and forth we seem to finally agree on the bit 3 (mask 0x08) to signal optional initial_routing_sync. Signed-off-by: Christian Decker --- lightningd/handshake/handshake.c | 5 ++++- lightningd/new_connection.c | 2 +- wire/peer_wire.h | 15 ++++++++++++++- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/lightningd/handshake/handshake.c b/lightningd/handshake/handshake.c index 10e2315d4..b474df781 100644 --- a/lightningd/handshake/handshake.c +++ b/lightningd/handshake/handshake.c @@ -970,7 +970,10 @@ static void exchange_init(int fd, struct crypto_state *cs, * #9](09-features.md), and MUST set to zero any feature bits that are * not defined. */ - u8 *msg = towire_init(NULL, NULL, NULL); + u8 *localfeatures = tal_arrz(NULL, u8, 1); + localfeatures[0] = LOCALFEATURES_INITIAL_ROUTING_SYNC; + u8 *msg = towire_init(NULL, NULL, localfeatures); + localfeatures = tal_free(localfeatures); if (!sync_crypto_write(cs, fd, msg)) status_failed(WIRE_INITMSG_WRITE_FAILED, "%s", strerror(errno)); diff --git a/lightningd/new_connection.c b/lightningd/new_connection.c index 181504dee..e84ac73c7 100644 --- a/lightningd/new_connection.c +++ b/lightningd/new_connection.c @@ -17,7 +17,7 @@ #include #include -const u8 supported_local_features[] = {0x03}; +const u8 supported_local_features[] = {LOCALFEATURES_INITIAL_ROUTING_SYNC}; const u8 supported_global_features[] = {0x00}; /* Before we have identified the peer, we just have a connection object. */ diff --git a/wire/peer_wire.h b/wire/peer_wire.h index e58b5307a..bfb0c9e39 100644 --- a/wire/peer_wire.h +++ b/wire/peer_wire.h @@ -26,7 +26,20 @@ bool is_gossip_msg(const u8 *cursor); * of the funding flow wishes to advertise this channel publicly to * the network as detailed within [BOLT #7] */ -#define CHANNEL_FLAGS_ANNOUNCE_CHANNEL 1 +#define CHANNEL_FLAGS_ANNOUNCE_CHANNEL 1 + +/* BOLT #7: + * + * Upon establishing a connection, the two endpoints negotiate whether + * to perform an initial sync by setting the `initial_routing_sync` + * flags in the `init` message. The endpoint SHOULD set the + * `initial_routing_sync` flag if it requires a full copy of the other + * endpoint's routing state. Upon receiving an init message with the + * `initial_routing_sync` flag set the node sends `channel_announcement`s, + * `channel_update`s and `node_announcement`s for all known channels and + * nodes as if they were just received. + */ +#define LOCALFEATURES_INITIAL_ROUTING_SYNC 0x08 /* Compare two short_channel_ids and return true if they are the equal */ bool short_channel_id_eq(const struct short_channel_id *a,