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

Function wait_index_bump

lightningd/wait.c:136–179  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

134}
135
136static u64 wait_index_bump(struct lightningd *ld,
137 struct db *db,
138 enum wait_subsystem subsystem,
139 enum wait_index index,
140 u64 num,
141 va_list ap_master)
142{
143 struct waiter *i, *n;
144 u64 *idxval = wait_index_ptr(ld, subsystem, index);
145
146 assert(!add_overflows_u64(*idxval, num));
147 (*idxval) += num;
148
149 /* FIXME: We can optimize this! It's always the max of the fields in
150 * the table, *unless* we delete one. So we can lazily write this on
151 * delete, and fix it up to MAX() when we startup. */
152 db_set_intvar(db,
153 tal_fmt(tmpctx, "last_%s_%s_index",
154 wait_subsystem_name(subsystem),
155 wait_index_name(index)),
156 *idxval);
157
158 list_for_each_safe(&ld->wait_commands, i, n, list) {
159 struct json_stream *response;
160 va_list ap;
161
162 if (*i->subsystem != subsystem)
163 continue;
164 if (*i->index != index)
165 continue;
166 if (*idxval < *i->nextval)
167 continue;
168
169 response = json_stream_success(i->cmd);
170 va_copy(ap, ap_master);
171 json_add_index(i->cmd, response, subsystem, index, *idxval, &ap);
172 va_end(ap);
173 /* Delete before freeing */
174 list_del_from(&ld->wait_commands, &i->list);
175 was_pending(command_success(i->cmd, response));
176 }
177
178 return *idxval;
179}
180
181u64 wait_index_increment(struct lightningd *ld,
182 struct db *db,

Callers 2

wait_index_incrementFunction · 0.85
wait_index_increaseFunction · 0.85

Calls 10

wait_index_ptrFunction · 0.85
add_overflows_u64Function · 0.85
db_set_intvarFunction · 0.85
json_add_indexFunction · 0.85
list_del_fromFunction · 0.85
wait_subsystem_nameFunction · 0.70
wait_index_nameFunction · 0.70
json_stream_successFunction · 0.70
was_pendingFunction · 0.70
command_successFunction · 0.70

Tested by

no test coverage detected