MCPcopy Create free account
hub / github.com/ElementsProject/lightning / new_peer

Function new_peer

lightningd/peer_control.c:86–121  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

84}
85
86struct peer *new_peer(struct lightningd *ld, u64 dbid,
87 const struct node_id *id,
88 const struct wireaddr_internal *addr,
89 const struct wireaddr *last_known_addr,
90 const u8 *their_features,
91 bool connected_incoming)
92{
93 /* We are owned by our channels, and freed manually by destroy_channel */
94 struct peer *peer = tal(NULL, struct peer);
95
96 peer->ld = ld;
97 peer->dbid = dbid;
98 peer->id = *id;
99 peer->uncommitted_channel = NULL;
100 peer->addr = *addr;
101 peer->last_known_addr = tal_dup_or_null(peer, struct wireaddr, last_known_addr);
102 peer->connected_incoming = connected_incoming;
103 peer->remote_addr = NULL;
104 list_head_init(&peer->channels);
105 peer->direction = node_id_idx(&peer->ld->our_nodeid, &peer->id);
106 peer->connected = PEER_DISCONNECTED;
107 peer->last_connect_attempt.ts.tv_sec
108 = peer->last_connect_attempt.ts.tv_nsec = 0;
109 if (their_features)
110 peer->their_features = tal_dup_talarr(peer, u8, their_features);
111 else
112 peer->their_features = NULL;
113
114 peer->dev_ignore_htlcs = false;
115
116 peer_node_id_map_add(ld->peers, peer);
117 if (dbid)
118 peer_dbid_map_add(ld->peers_by_dbid, peer);
119 tal_add_destructor(peer, destroy_peer);
120 return peer;
121}
122
123static void delete_peer(struct peer *peer)
124{

Callers 2

handle_peer_connectedFunction · 0.70
stub_chanFunction · 0.70

Calls 2

list_head_initFunction · 0.85
node_id_idxFunction · 0.85

Tested by

no test coverage detected