core-lightning/lightningd/gossip_msg.h
Rusty Russell 66dcba099d gossipd: hand raw pubkeys in getnodes and getchannels entries.
We spend quite a bit of time in libsecp256k1 moving them to and from
DER encoding.  With a bit of care, we can transfer the raw bytes from
gossipd and manually decode them so a malformed one can't make us
abort().

Before:
	real	0m0.629000-0.695000(0.64985+/-0.019)s

After:
	real	0m0.359000-0.433000(0.37645+/-0.023)s

At this point, the main issues are 11% of time spent in ccan/io's
backend_wake (I tried using a hash table there, but that actually makes
the small-number-of-fds case slower), and 65% of gossipd's time is
in marshalling the response (all those tal_resize add up!).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-10-19 22:02:11 +00:00

60 lines
1.8 KiB
C

#ifndef LIGHTNING_LIGHTNINGD_GOSSIP_MSG_H
#define LIGHTNING_LIGHTNINGD_GOSSIP_MSG_H
#include "config.h"
#include <bitcoin/pubkey.h>
#include <gossipd/routing.h>
struct route_info;
struct peer_features {
u8 *localfeatures;
u8 *globalfeatures;
};
struct gossip_getnodes_entry {
/* This is raw to optimize marshaling: be careful! */
u8 nodeid[sizeof(struct pubkey)];
s64 last_timestamp; /* -1 means never: following fields ignored */
u8 *globalfeatures;
struct wireaddr *addresses;
u8 alias[32];
u8 color[3];
};
struct gossip_getchannels_entry {
/* These are raw to optimize marshaling: be careful! */
u8 source[sizeof(struct pubkey)], destination[sizeof(struct pubkey)];
u64 satoshis;
struct short_channel_id short_channel_id;
u8 message_flags;
u8 channel_flags;
bool public;
bool local_disabled;
u32 last_update_timestamp;
u32 delay;
u32 base_fee_msat;
u32 fee_per_millionth;
};
struct gossip_getnodes_entry *
fromwire_gossip_getnodes_entry(const tal_t *ctx, const u8 **pptr, size_t *max);
void towire_gossip_getnodes_entry(u8 **pptr,
const struct gossip_getnodes_entry *entry);
struct peer_features *
fromwire_peer_features(const tal_t *ctx, const u8 **pptr, size_t *max);
void towire_peer_features(u8 **pptr, const struct peer_features *features);
void fromwire_route_hop(const u8 **pprt, size_t *max, struct route_hop *entry);
void towire_route_hop(u8 **pprt, const struct route_hop *entry);
void fromwire_route_info(const u8 **pprt, size_t *max, struct route_info *entry);
void towire_route_info(u8 **pprt, const struct route_info *entry);
void fromwire_gossip_getchannels_entry(const u8 **pptr, size_t *max,
struct gossip_getchannels_entry *entry);
void towire_gossip_getchannels_entry(
u8 **pptr, const struct gossip_getchannels_entry *entry);
#endif /* LIGHTNING_LIGHTNINGD_GOSSIP_MSG_H */