Browse Source

lightningd: remove peer->log in favor of channel->log.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ppa-0.6.1
Rusty Russell 7 years ago
committed by Christian Decker
parent
commit
8f48a72d74
  1. 6
      lightningd/channel.c
  2. 7
      lightningd/peer_control.c
  3. 3
      lightningd/peer_control.h

6
lightningd/channel.c

@ -104,6 +104,7 @@ struct channel *new_channel(struct peer *peer, u64 dbid, u32 first_blocknum)
{
/* FIXME: We currently rely on it being all zero/NULL */
struct channel *channel = talz(peer->ld, struct channel);
char *idname;
channel->dbid = dbid;
channel->peer = peer;
@ -112,8 +113,11 @@ struct channel *new_channel(struct peer *peer, u64 dbid, u32 first_blocknum)
channel->local_shutdown_idx = -1;
/* FIXME: update log prefix when we get scid */
/* FIXME: Use minimal unique pubkey prefix for logs! */
idname = type_to_string(peer, struct pubkey, &peer->id);
channel->log = new_log(channel, peer->log_book, "%s chan #%"PRIu64":",
log_prefix(peer->log), dbid);
idname, dbid);
tal_free(idname);
list_add_tail(&peer->channels, &channel->list);
tal_add_destructor(channel, destroy_channel);
if (channel->dbid != 0)

7
lightningd/peer_control.c

@ -106,7 +106,6 @@ struct peer *new_peer(struct lightningd *ld, u64 dbid,
{
/* We are owned by our channels, and freed manually by destroy_channel */
struct peer *peer = tal(NULL, struct peer);
const char *idname;
peer->ld = ld;
peer->dbid = dbid;
@ -121,10 +120,6 @@ struct peer *new_peer(struct lightningd *ld, u64 dbid,
/* Max 128k per peer. */
peer->log_book = new_log_book(peer, 128*1024,
get_log_level(ld->log_book));
/* FIXME: Use minimal unique pubkey prefix for logs! */
idname = type_to_string(peer, struct pubkey, id);
peer->log = new_log(peer, peer->log_book, "peer %s:", idname);
tal_free(idname);
set_log_outfn(peer->log_book, copy_to_parent_log, peer);
list_add_tail(&ld->peers, &peer->list);
tal_add_destructor(peer, destroy_peer);
@ -327,7 +322,7 @@ void peer_connected(struct lightningd *ld, const u8 *msg,
/* FIXME: Only consider active channels! */
struct channel *channel = peer2channel(peer);
log_debug(peer->log, "Peer has reconnected, state %s",
log_debug(channel->log, "Peer has reconnected, state %s",
channel_state_name(channel));
/* FIXME: We can have errors for multiple channels. */

3
lightningd/peer_control.h

@ -37,9 +37,6 @@ struct peer {
/* History */
struct log_book *log_book;
/* FIXME: Remove in favor of channel->log */
struct log *log;
/* Where we connected to, or it connected from. */
struct wireaddr addr;

Loading…
Cancel
Save