gossipd/gossip_constants.h: Single place for BOLT constants.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2018-05-17 14:38:11 +09:30 committed by Christian Decker
parent b965ef7d1d
commit 540c68d7ca
7 changed files with 39 additions and 17 deletions

View File

@ -93,7 +93,7 @@ channeld/gen_full_channel_error_names.h: channeld/full_channel_error.h ccan/ccan
ccan/ccan/cdump/tools/cdump-enumstr channeld/full_channel_error.h > $@ ccan/ccan/cdump/tools/cdump-enumstr channeld/full_channel_error.h > $@
$(LIGHTNINGD_CHANNEL_OBJS): $(LIGHTNINGD_HEADERS) $(LIGHTNINGD_CHANNEL_OBJS): $(LIGHTNINGD_HEADERS) $(LIGHTNINGD_GOSSIP_CONTROL_HEADERS)
channeld/gen_channel_wire.h: $(WIRE_GEN) channeld/channel_wire.csv channeld/gen_channel_wire.h: $(WIRE_GEN) channeld/channel_wire.csv
$(WIRE_GEN) --header $@ channel_wire_type < channeld/channel_wire.csv > $@ $(WIRE_GEN) --header $@ channel_wire_type < channeld/channel_wire.csv > $@

View File

@ -46,7 +46,7 @@
#include <errno.h> #include <errno.h>
#include <fcntl.h> #include <fcntl.h>
#include <gossipd/gen_gossip_wire.h> #include <gossipd/gen_gossip_wire.h>
#include <gossipd/routing.h> #include <gossipd/gossip_constants.h>
#include <hsmd/gen_hsm_client_wire.h> #include <hsmd/gen_hsm_client_wire.h>
#include <inttypes.h> #include <inttypes.h>
#include <secp256k1.h> #include <secp256k1.h>

View File

@ -7,7 +7,7 @@ gossipd-wrongdir:
default: gossipd-all default: gossipd-all
# Control daemon uses this: # Control daemon uses this:
LIGHTNINGD_GOSSIP_CONTROL_HEADERS := gossipd/gen_gossip_wire.h LIGHTNINGD_GOSSIP_CONTROL_HEADERS := gossipd/gen_gossip_wire.h gossipd/gossip_constants.h
LIGHTNINGD_GOSSIP_CONTROL_SRC := gossipd/gen_gossip_wire.c LIGHTNINGD_GOSSIP_CONTROL_SRC := gossipd/gen_gossip_wire.c
LIGHTNINGD_GOSSIP_CONTROL_OBJS := $(LIGHTNINGD_GOSSIP_CONTROL_SRC:.c=.o) LIGHTNINGD_GOSSIP_CONTROL_OBJS := $(LIGHTNINGD_GOSSIP_CONTROL_SRC:.c=.o)
@ -28,7 +28,7 @@ LIGHTNINGD_GOSSIP_OBJS := $(LIGHTNINGD_GOSSIP_SRC:.c=.o)
# Make sure these depend on everything. # Make sure these depend on everything.
ALL_OBJS += $(LIGHTNINGD_GOSSIP_OBJS) ALL_OBJS += $(LIGHTNINGD_GOSSIP_OBJS)
ALL_PROGRAMS += lightningd/lightning_gossipd ALL_PROGRAMS += lightningd/lightning_gossipd
ALL_GEN_HEADERS += $(LIGHTNINGD_GOSSIP_CONTROL_HEADERS) ALL_GEN_HEADERS += gossipd/gen_gossip_wire.h
# For checking # For checking
LIGHTNINGD_GOSSIP_ALLSRC_NOGEN := $(filter-out gossipd/gen_%, $(LIGHTNINGD_GOSSIP_CLIENT_SRC) $(LIGHTNINGD_GOSSIP_SRC)) LIGHTNINGD_GOSSIP_ALLSRC_NOGEN := $(filter-out gossipd/gen_%, $(LIGHTNINGD_GOSSIP_CLIENT_SRC) $(LIGHTNINGD_GOSSIP_SRC))

View File

@ -0,0 +1,33 @@
#ifndef LIGHTNING_GOSSIPD_GOSSIP_CONSTANTS_H
#define LIGHTNING_GOSSIPD_GOSSIP_CONSTANTS_H
/* BOLT #4:
*
* - Length: the maximum route length is limited to 20 hops.
*...
* 1. type: `onion_packet`
* 2. data:
* * [`1`:`version`]
* * [`33`:`public_key`]
* * [`20*65`:`hops_data`]
*/
#define ROUTING_MAX_HOPS 20
/* BOLT #7:
*
* The `flags` bitfield...individual bits:
*...
* | 0 | `direction` | Direction this update refers to. |
* | 1 | `disable` | Disable the channel. |
*/
#define ROUTING_FLAGS_DIRECTION (1 << 0)
#define ROUTING_FLAGS_DISABLED (1 << 1)
/* BOLT #7:
*
* - MUST NOT send `announcement_signatures` messages until `funding_locked`
* has been sent AND the funding transaction has at least six confirmations.
*/
#define ANNOUNCE_MIN_DEPTH 6
#endif /* LIGHTNING_GOSSIPD_GOSSIP_CONSTANTS_H */

View File

@ -6,21 +6,11 @@
#include <ccan/htable/htable_type.h> #include <ccan/htable/htable_type.h>
#include <ccan/time/time.h> #include <ccan/time/time.h>
#include <gossipd/broadcast.h> #include <gossipd/broadcast.h>
#include <gossipd/gossip_constants.h>
#include <gossipd/gossip_store.h> #include <gossipd/gossip_store.h>
#include <wire/gen_onion_wire.h> #include <wire/gen_onion_wire.h>
#include <wire/wire.h> #include <wire/wire.h>
#define ROUTING_MAX_HOPS 20
/* BOLT #7:
*
* The `flags` bitfield...individual bits:
*...
* | 0 | `direction` | Direction this update refers to. |
* | 1 | `disable` | Disable the channel. |
*/
#define ROUTING_FLAGS_DIRECTION (1 << 0)
#define ROUTING_FLAGS_DISABLED (1 << 1)
struct half_chan { struct half_chan {
/* Cached `channel_update` which initialized below (or NULL) */ /* Cached `channel_update` which initialized below (or NULL) */
const u8 *channel_update; const u8 *channel_update;

View File

@ -2,6 +2,7 @@
#include <ccan/fdpass/fdpass.h> #include <ccan/fdpass/fdpass.h>
#include <channeld/gen_channel_wire.h> #include <channeld/gen_channel_wire.h>
#include <errno.h> #include <errno.h>
#include <gossipd/gossip_constants.h>
#include <hsmd/capabilities.h> #include <hsmd/capabilities.h>
#include <hsmd/gen_hsm_client_wire.h> #include <hsmd/gen_hsm_client_wire.h>
#include <inttypes.h> #include <inttypes.h>

View File

@ -14,8 +14,6 @@
#include <wallet/wallet.h> #include <wallet/wallet.h>
#include <wire/peer_wire.h> #include <wire/peer_wire.h>
#define ANNOUNCE_MIN_DEPTH 6
struct crypto_state; struct crypto_state;
struct peer { struct peer {