mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-03 18:57:06 +01:00
gossip: Use the utxoset to shortcircuit the txout lookup
Signed-off-by: Christian Decker <decker.christian@gmail.com>
This commit is contained in:
parent
387ba76920
commit
cb4ba9bf4f
1 changed files with 14 additions and 5 deletions
|
@ -81,6 +81,7 @@ static void got_txout(struct bitcoind *bitcoind,
|
||||||
static void get_txout(struct subd *gossip, const u8 *msg)
|
static void get_txout(struct subd *gossip, const u8 *msg)
|
||||||
{
|
{
|
||||||
struct short_channel_id *scid = tal(gossip, struct short_channel_id);
|
struct short_channel_id *scid = tal(gossip, struct short_channel_id);
|
||||||
|
struct outpoint *op;
|
||||||
|
|
||||||
if (!fromwire_gossip_get_txout(msg, scid))
|
if (!fromwire_gossip_get_txout(msg, scid))
|
||||||
fatal("Gossip gave bad GOSSIP_GET_TXOUT message %s",
|
fatal("Gossip gave bad GOSSIP_GET_TXOUT message %s",
|
||||||
|
@ -88,11 +89,19 @@ static void get_txout(struct subd *gossip, const u8 *msg)
|
||||||
|
|
||||||
/* FIXME: Block less than 6 deep? */
|
/* FIXME: Block less than 6 deep? */
|
||||||
|
|
||||||
bitcoind_getoutput(gossip->ld->topology->bitcoind,
|
op = wallet_outpoint_for_scid(gossip->ld->wallet, scid, scid);
|
||||||
short_channel_id_blocknum(scid),
|
|
||||||
short_channel_id_txnum(scid),
|
if (op) {
|
||||||
short_channel_id_outnum(scid),
|
subd_send_msg(gossip, towire_gossip_get_txout_reply(
|
||||||
got_txout, scid);
|
scid, scid, op->scriptpubkey));
|
||||||
|
tal_free(scid);
|
||||||
|
} else {
|
||||||
|
bitcoind_getoutput(gossip->ld->topology->bitcoind,
|
||||||
|
short_channel_id_blocknum(scid),
|
||||||
|
short_channel_id_txnum(scid),
|
||||||
|
short_channel_id_outnum(scid),
|
||||||
|
got_txout, scid);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned gossip_msg(struct subd *gossip, const u8 *msg, const int *fds)
|
static unsigned gossip_msg(struct subd *gossip, const u8 *msg, const int *fds)
|
||||||
|
|
Loading…
Add table
Reference in a new issue