mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-03 10:46:58 +01:00
gossip_store: avoid gratuitous copy on load.
Doesn't make measurable difference, but an obvious optimization. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
617c23e735
commit
62918fcb3b
2 changed files with 17 additions and 3 deletions
|
@ -327,7 +327,7 @@ void gossip_store_load(struct routing_state *rstate, struct gossip_store *gs)
|
||||||
&gossip_msg,
|
&gossip_msg,
|
||||||
&satoshis)) {
|
&satoshis)) {
|
||||||
if (!routing_add_channel_announcement(rstate,
|
if (!routing_add_channel_announcement(rstate,
|
||||||
gossip_msg,
|
take(gossip_msg),
|
||||||
satoshis)) {
|
satoshis)) {
|
||||||
bad = "Bad channel_announcement";
|
bad = "Bad channel_announcement";
|
||||||
goto truncate;
|
goto truncate;
|
||||||
|
@ -335,14 +335,16 @@ void gossip_store_load(struct routing_state *rstate, struct gossip_store *gs)
|
||||||
stats[0]++;
|
stats[0]++;
|
||||||
} else if (fromwire_gossip_store_channel_update(msg, msg,
|
} else if (fromwire_gossip_store_channel_update(msg, msg,
|
||||||
&gossip_msg)) {
|
&gossip_msg)) {
|
||||||
if (!routing_add_channel_update(rstate, gossip_msg)) {
|
if (!routing_add_channel_update(rstate,
|
||||||
|
take(gossip_msg))) {
|
||||||
bad = "Bad channel_update";
|
bad = "Bad channel_update";
|
||||||
goto truncate;
|
goto truncate;
|
||||||
}
|
}
|
||||||
stats[1]++;
|
stats[1]++;
|
||||||
} else if (fromwire_gossip_store_node_announcement(msg, msg,
|
} else if (fromwire_gossip_store_node_announcement(msg, msg,
|
||||||
&gossip_msg)) {
|
&gossip_msg)) {
|
||||||
if (!routing_add_node_announcement(rstate, gossip_msg)) {
|
if (!routing_add_node_announcement(rstate,
|
||||||
|
take(gossip_msg))) {
|
||||||
bad = "Bad node_announcement";
|
bad = "Bad node_announcement";
|
||||||
goto truncate;
|
goto truncate;
|
||||||
}
|
}
|
||||||
|
|
|
@ -889,6 +889,10 @@ bool routing_add_channel_announcement(struct routing_state *rstate,
|
||||||
struct pubkey bitcoin_key_1;
|
struct pubkey bitcoin_key_1;
|
||||||
struct pubkey bitcoin_key_2;
|
struct pubkey bitcoin_key_2;
|
||||||
|
|
||||||
|
/* Make sure we own msg, even if we don't save it. */
|
||||||
|
if (taken(msg))
|
||||||
|
tal_steal(tmpctx, msg);
|
||||||
|
|
||||||
if (!fromwire_channel_announcement(
|
if (!fromwire_channel_announcement(
|
||||||
tmpctx, msg, &node_signature_1, &node_signature_2,
|
tmpctx, msg, &node_signature_1, &node_signature_2,
|
||||||
&bitcoin_signature_1, &bitcoin_signature_2, &features, &chain_hash,
|
&bitcoin_signature_1, &bitcoin_signature_2, &features, &chain_hash,
|
||||||
|
@ -1228,6 +1232,10 @@ bool routing_add_channel_update(struct routing_state *rstate,
|
||||||
struct chan *chan;
|
struct chan *chan;
|
||||||
u8 direction;
|
u8 direction;
|
||||||
|
|
||||||
|
/* Make sure we own msg, even if we don't save it. */
|
||||||
|
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, ×tamp,
|
&short_channel_id, ×tamp,
|
||||||
&message_flags, &channel_flags,
|
&message_flags, &channel_flags,
|
||||||
|
@ -1499,6 +1507,10 @@ bool routing_add_node_announcement(struct routing_state *rstate, const u8 *msg T
|
||||||
u8 *features, *addresses;
|
u8 *features, *addresses;
|
||||||
struct wireaddr *wireaddrs;
|
struct wireaddr *wireaddrs;
|
||||||
|
|
||||||
|
/* Make sure we own msg, even if we don't save it. */
|
||||||
|
if (taken(msg))
|
||||||
|
tal_steal(tmpctx, msg);
|
||||||
|
|
||||||
/* Note: validity of node_id is already checked. */
|
/* Note: validity of node_id is already checked. */
|
||||||
if (!fromwire_node_announcement(tmpctx, msg,
|
if (!fromwire_node_announcement(tmpctx, msg,
|
||||||
&signature, &features, ×tamp,
|
&signature, &features, ×tamp,
|
||||||
|
|
Loading…
Add table
Reference in a new issue