gossipd: don't use peer softrefs for gossip credit.

We use a "softref" which is a magic pointer which gets NULL'ed when
the object is freed.  But it's heavy, and a bit tricky to use, and we
only use it in gossipd.

Instead, keep the nodeid, and do a lookup (now that's fast) if we want
to credit the sender for valid gossip.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2023-07-06 17:05:54 +09:30
parent 6e2a34373c
commit 17e0c057aa
11 changed files with 117 additions and 101 deletions

View File

@@ -808,7 +808,7 @@ const u8 *handle_reply_channel_range(struct peer *peer, const u8 *msg)
/* Credit peer for answering gossip, so seeker doesn't get upset:
* since scids are only 8 bytes, use a discount over normal gossip. */
peer_supplied_good_gossip(peer, tal_count(scids) / 20);
peer_supplied_good_gossip(peer->daemon, &peer->id, tal_count(scids) / 20);
/* Old code used to set this to 1 all the time; not setting it implies
* we're talking to an upgraded node. */