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

Function upgrade_field

devtools/convert-gossmap.c:18–60  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16#define GOSSIP_STORE_ZOMBIE_BIT_V13 0x1000U
17
18static bool upgrade_field(u8 oldversion,
19 be16 *hdr_flags,
20 u8 **msg)
21{
22 int type = fromwire_peektype(*msg);
23
24 switch (oldversion) {
25 case 10:
26 /* Remove old channel_update with no htlc_maximum_msat */
27 if (type == WIRE_CHANNEL_UPDATE
28 && tal_bytelen(*msg) == 130) {
29 *msg = tal_free(*msg);
30 return true;
31 }
32 /* fall thru */
33 case 11:
34 case 12:
35 /* Remove private entries */
36 if (type == WIRE_GOSSIP_STORE_PRIVATE_CHANNEL_OBS) {
37 *msg = tal_free(*msg);
38 return true;
39 } else if (type == WIRE_GOSSIP_STORE_PRIVATE_UPDATE_OBS) {
40 *msg = tal_free(*msg);
41 return true;
42 }
43 /* fall thru */
44 case 13:
45 /* Discard any zombies */
46 if (be16_to_cpu(*hdr_flags) & GOSSIP_STORE_ZOMBIE_BIT_V13) {
47 *msg = tal_free(*msg);
48 return true;
49 }
50 case 14:
51 /* Add completed field */
52 *hdr_flags |= CPU_TO_BE16(GOSSIP_STORE_COMPLETED_BIT);
53 /* fall thru */
54 case 15:
55 /* Noop */
56 return true;
57 }
58
59 return false;
60}
61
62int main(int argc, char *argv[])
63{

Callers 1

mainFunction · 0.70

Calls 4

fromwire_peektypeFunction · 0.85
tal_bytelenFunction · 0.85
tal_freeFunction · 0.85
be16_to_cpuFunction · 0.85

Tested by

no test coverage detected