Browse Source

daemon: peer needs to know who offered the anchor.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ppa-0.6.1
Rusty Russell 9 years ago
parent
commit
0376e08fea
  1. 8
      daemon/peer.c
  2. 4
      daemon/peer.h

8
daemon/peer.c

@ -59,6 +59,7 @@ static void destroy_peer(struct peer *peer)
static struct peer *new_peer(struct lightningd_state *state,
struct io_conn *conn,
int addr_type, int addr_protocol,
enum state_input offer_anchor,
const char *in_or_out)
{
struct peer *peer = tal(state, struct peer);
@ -71,6 +72,9 @@ static struct peer *new_peer(struct lightningd_state *state,
peer->addr.protocol = addr_protocol;
peer->io_data = NULL;
peer->secrets = NULL;
peer->offer_anchor = offer_anchor;
assert(offer_anchor == CMD_OPEN_WITH_ANCHOR
|| offer_anchor == CMD_OPEN_WITHOUT_ANCHOR);
list_head_init(&peer->watches);
/* FIXME: Attach IO logging for this peer. */
@ -97,7 +101,7 @@ static struct io_plan *peer_connected_out(struct io_conn *conn,
{
struct json_result *response;
struct peer *peer = new_peer(state, conn, SOCK_STREAM, IPPROTO_TCP,
"out");
CMD_OPEN_WITH_ANCHOR, "out");
if (!peer) {
command_fail(connect->cmd, "Failed to make peer for %s:%s",
connect->name, connect->port);
@ -118,7 +122,7 @@ static struct io_plan *peer_connected_in(struct io_conn *conn,
struct lightningd_state *state)
{
struct peer *peer = new_peer(state, conn, SOCK_STREAM, IPPROTO_TCP,
"in");
CMD_OPEN_WITHOUT_ANCHOR, "in");
if (!peer)
return io_close(conn);

4
daemon/peer.h

@ -4,6 +4,7 @@
#include "bitcoin/pubkey.h"
#include "lightning.pb-c.h"
#include "netaddr.h"
#include "state_types.h"
#include <ccan/list/list.h>
struct peer {
@ -31,6 +32,9 @@ struct peer {
/* Things we're watching for (see watches.c) */
struct list_head watches;
/* Did we offer an anchor? */
enum state_input offer_anchor;
/* Keys for transactions with this peer. */
struct pubkey their_commitkey, their_finalkey;
struct pubkey our_commitkey, our_finalkey;

Loading…
Cancel
Save