| 82 | } |
| 83 | |
| 84 | struct peer *new_peer(struct lightningd *ld, u64 dbid, |
| 85 | const struct node_id *id, |
| 86 | const struct wireaddr_internal *addr, |
| 87 | bool connected_incoming) |
| 88 | { |
| 89 | /* We are owned by our channels, and freed manually by destroy_channel */ |
| 90 | struct peer *peer = tal(NULL, struct peer); |
| 91 | |
| 92 | peer->ld = ld; |
| 93 | peer->dbid = dbid; |
| 94 | peer->id = *id; |
| 95 | peer->uncommitted_channel = NULL; |
| 96 | peer->addr = *addr; |
| 97 | peer->connected_incoming = connected_incoming; |
| 98 | peer->remote_addr = NULL; |
| 99 | peer->their_features = NULL; |
| 100 | list_head_init(&peer->channels); |
| 101 | peer->direction = node_id_idx(&peer->ld->id, &peer->id); |
| 102 | peer->connected = PEER_DISCONNECTED; |
| 103 | peer->last_connect_attempt.ts.tv_sec |
| 104 | = peer->last_connect_attempt.ts.tv_nsec = 0; |
| 105 | #if DEVELOPER |
| 106 | peer->ignore_htlcs = false; |
| 107 | #endif |
| 108 | |
| 109 | list_add_tail(&ld->peers, &peer->list); |
| 110 | tal_add_destructor(peer, destroy_peer); |
| 111 | return peer; |
| 112 | } |
| 113 | |
| 114 | static void delete_peer(struct peer *peer) |
| 115 | { |
no test coverage detected