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

Function new_peer

lightningd/peer_control.c:93–128  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

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