bitcoind_sendrawtx: tie the sending of the transaction to the particular peer.

Not important just yet, but it will be soon.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2016-11-07 22:58:02 +10:30
parent cc9ffe6c40
commit 7d1137c45e
3 changed files with 11 additions and 8 deletions

View file

@ -282,13 +282,14 @@ static void process_sendrawtx(struct bitcoin_cli *bcli)
cb(bcli->dstate, msg, bcli->cb_arg);
}
void bitcoind_sendrawtx_(struct lightningd_state *dstate,
void bitcoind_sendrawtx_(struct peer *peer,
struct lightningd_state *dstate,
const char *hextx,
void (*cb)(struct lightningd_state *dstate,
const char *msg, void *),
void *arg)
{
start_bitcoin_cli(dstate, NULL, process_sendrawtx, true, cb, arg,
start_bitcoin_cli(dstate, peer, process_sendrawtx, true, cb, arg,
"sendrawtransaction", hextx, NULL);
}

View file

@ -27,14 +27,15 @@ void bitcoind_estimate_fee_(struct lightningd_state *dstate,
u64), \
(arg))
void bitcoind_sendrawtx_(struct lightningd_state *dstate,
void bitcoind_sendrawtx_(struct peer *peer,
struct lightningd_state *dstate,
const char *hextx,
void (*cb)(struct lightningd_state *dstate,
const char *msg, void *),
void *arg);
#define bitcoind_sendrawtx(dstate, hextx, cb, arg) \
bitcoind_sendrawtx_((dstate), (hextx), \
#define bitcoind_sendrawtx(peer_, dstate, hextx, cb, arg) \
bitcoind_sendrawtx_((peer_), (dstate), (hextx), \
typesafe_cb_preargs(void, void *, \
(cb), (arg), \
struct lightningd_state *, \

View file

@ -237,7 +237,7 @@ static void try_broadcast(struct lightningd_state *dstate,
this_tx = txs[num_txs-1];
tal_resize(&txs, num_txs-1);
bitcoind_sendrawtx(dstate, this_tx, try_broadcast, txs);
bitcoind_sendrawtx(NULL, dstate, this_tx, try_broadcast, txs);
}
/* FIXME: This is dumb. We can group txs and avoid bothering bitcoind
@ -266,7 +266,8 @@ static void rebroadcast_txs(struct lightningd_state *dstate)
}
if (num_txs)
bitcoind_sendrawtx(dstate, txs[num_txs-1], try_broadcast, txs);
bitcoind_sendrawtx(NULL, dstate, txs[num_txs-1],
try_broadcast, txs);
else
tal_free(txs);
}
@ -291,7 +292,7 @@ void broadcast_tx(struct peer *peer, const struct bitcoin_tx *tx)
rawtx = linearize_tx(txs, otx->tx);
txs[0] = tal_hexstr(txs, rawtx, tal_count(rawtx));
bitcoind_sendrawtx(peer->dstate, txs[0], try_broadcast, txs);
bitcoind_sendrawtx(peer, peer->dstate, txs[0], try_broadcast, txs);
}
static void free_blocks(struct lightningd_state *dstate, struct block *b)