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:
Rusty Russell 2016-11-09 08:04:28 +10:30
parent 536a48940e
commit 7f0a56f674
3 changed files with 7 additions and 17 deletions

View File

@ -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));
}
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);
@ -88,14 +88,10 @@ void queue_pkt_open(struct peer *peer, OpenChannel__AnchorOffer anchor)
o->delay->locktime_case = LOCKTIME__LOCKTIME_BLOCKS;
o->delay->blocks = rel_locktime_to_blocks(&peer->local.locktime);
o->initial_fee_rate = peer->local.commit_fee_rate;
if (anchor == OPEN_CHANNEL__ANCHOR_OFFER__WILL_CREATE_ANCHOR)
assert(peer->local.offer_anchor);
else {
assert(anchor == OPEN_CHANNEL__ANCHOR_OFFER__WONT_CREATE_ANCHOR);
assert(!peer->local.offer_anchor);
}
o->anch = anchor;
if (offer_anchor)
o->anch = OPEN_CHANNEL__ANCHOR_OFFER__WILL_CREATE_ANCHOR;
else
o->anch = OPEN_CHANNEL__ANCHOR_OFFER__WONT_CREATE_ANCHOR;
o->min_depth = peer->local.mindepth;
queue_pkt(peer, PKT__PKT_OPEN, o);
}

View File

@ -10,7 +10,7 @@ struct bitcoin_signature;
struct commit_info;
/* 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_open_commit_sig(struct peer *peer);
void queue_pkt_open_complete(struct peer *peer);

View File

@ -2555,8 +2555,6 @@ static struct io_plan *peer_send_init(struct io_conn *conn, struct peer *peer)
/* Crypto is on, we are live. */
static struct io_plan *peer_crypto_on(struct io_conn *conn, struct peer *peer)
{
OpenChannel__AnchorOffer anchor;
peer_secrets_init(peer);
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);
/* 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
* 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_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);
}