mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-20 15:44:21 +01:00
queue_pkt_open: take bool for API.
No need to leak protobuf enum outside. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -72,7 +72,7 @@ static void queue_pkt(struct peer *peer, Pkt__PktCase type, const void *msg)
|
|||||||
queue_raw_pkt(peer, make_pkt(peer, type, msg));
|
queue_raw_pkt(peer, make_pkt(peer, type, msg));
|
||||||
}
|
}
|
||||||
|
|
||||||
void queue_pkt_open(struct peer *peer, OpenChannel__AnchorOffer anchor)
|
void queue_pkt_open(struct peer *peer, bool offer_anchor)
|
||||||
{
|
{
|
||||||
OpenChannel *o = tal(peer, OpenChannel);
|
OpenChannel *o = tal(peer, OpenChannel);
|
||||||
|
|
||||||
@@ -88,14 +88,10 @@ void queue_pkt_open(struct peer *peer, OpenChannel__AnchorOffer anchor)
|
|||||||
o->delay->locktime_case = LOCKTIME__LOCKTIME_BLOCKS;
|
o->delay->locktime_case = LOCKTIME__LOCKTIME_BLOCKS;
|
||||||
o->delay->blocks = rel_locktime_to_blocks(&peer->local.locktime);
|
o->delay->blocks = rel_locktime_to_blocks(&peer->local.locktime);
|
||||||
o->initial_fee_rate = peer->local.commit_fee_rate;
|
o->initial_fee_rate = peer->local.commit_fee_rate;
|
||||||
if (anchor == OPEN_CHANNEL__ANCHOR_OFFER__WILL_CREATE_ANCHOR)
|
if (offer_anchor)
|
||||||
assert(peer->local.offer_anchor);
|
o->anch = OPEN_CHANNEL__ANCHOR_OFFER__WILL_CREATE_ANCHOR;
|
||||||
else {
|
else
|
||||||
assert(anchor == OPEN_CHANNEL__ANCHOR_OFFER__WONT_CREATE_ANCHOR);
|
o->anch = OPEN_CHANNEL__ANCHOR_OFFER__WONT_CREATE_ANCHOR;
|
||||||
assert(!peer->local.offer_anchor);
|
|
||||||
}
|
|
||||||
|
|
||||||
o->anch = anchor;
|
|
||||||
o->min_depth = peer->local.mindepth;
|
o->min_depth = peer->local.mindepth;
|
||||||
queue_pkt(peer, PKT__PKT_OPEN, o);
|
queue_pkt(peer, PKT__PKT_OPEN, o);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ struct bitcoin_signature;
|
|||||||
struct commit_info;
|
struct commit_info;
|
||||||
|
|
||||||
/* Send various kinds of packets */
|
/* Send various kinds of packets */
|
||||||
void queue_pkt_open(struct peer *peer, OpenChannel__AnchorOffer anchor);
|
void queue_pkt_open(struct peer *peer, bool offer_anchor);
|
||||||
void queue_pkt_anchor(struct peer *peer);
|
void queue_pkt_anchor(struct peer *peer);
|
||||||
void queue_pkt_open_commit_sig(struct peer *peer);
|
void queue_pkt_open_commit_sig(struct peer *peer);
|
||||||
void queue_pkt_open_complete(struct peer *peer);
|
void queue_pkt_open_complete(struct peer *peer);
|
||||||
|
|||||||
@@ -2555,8 +2555,6 @@ static struct io_plan *peer_send_init(struct io_conn *conn, struct peer *peer)
|
|||||||
/* Crypto is on, we are live. */
|
/* Crypto is on, we are live. */
|
||||||
static struct io_plan *peer_crypto_on(struct io_conn *conn, struct peer *peer)
|
static struct io_plan *peer_crypto_on(struct io_conn *conn, struct peer *peer)
|
||||||
{
|
{
|
||||||
OpenChannel__AnchorOffer anchor;
|
|
||||||
|
|
||||||
peer_secrets_init(peer);
|
peer_secrets_init(peer);
|
||||||
|
|
||||||
peer_get_revocation_hash(peer, 0, &peer->local.next_revocation_hash);
|
peer_get_revocation_hash(peer, 0, &peer->local.next_revocation_hash);
|
||||||
@@ -2566,10 +2564,6 @@ static struct io_plan *peer_crypto_on(struct io_conn *conn, struct peer *peer)
|
|||||||
set_peer_state(peer, STATE_OPEN_WAIT_FOR_OPENPKT, __func__, false);
|
set_peer_state(peer, STATE_OPEN_WAIT_FOR_OPENPKT, __func__, false);
|
||||||
|
|
||||||
/* FIXME: Start timeout, and close peer if they don't progress! */
|
/* FIXME: Start timeout, and close peer if they don't progress! */
|
||||||
if (peer->local.offer_anchor)
|
|
||||||
anchor = OPEN_CHANNEL__ANCHOR_OFFER__WILL_CREATE_ANCHOR;
|
|
||||||
else
|
|
||||||
anchor = OPEN_CHANNEL__ANCHOR_OFFER__WONT_CREATE_ANCHOR;
|
|
||||||
|
|
||||||
/* FIXME: Delay db write until we have something to keep, or handle
|
/* FIXME: Delay db write until we have something to keep, or handle
|
||||||
* reconnect with STATE_INIT state. */
|
* reconnect with STATE_INIT state. */
|
||||||
@@ -2582,7 +2576,7 @@ static struct io_plan *peer_crypto_on(struct io_conn *conn, struct peer *peer)
|
|||||||
peer->local.commit->revocation_hash = peer->local.next_revocation_hash;
|
peer->local.commit->revocation_hash = peer->local.next_revocation_hash;
|
||||||
peer_get_revocation_hash(peer, 1, &peer->local.next_revocation_hash);
|
peer_get_revocation_hash(peer, 1, &peer->local.next_revocation_hash);
|
||||||
|
|
||||||
queue_pkt_open(peer, anchor);
|
queue_pkt_open(peer, peer->local.offer_anchor);
|
||||||
return peer_send_init(conn,peer);
|
return peer_send_init(conn,peer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user