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

Function extract_scid

plugins/sql.c:988–1019  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

986}
987
988static bool extract_scid(int gosstore_fd, size_t off, u16 type,
989 struct short_channel_id *scid)
990{
991 be64 raw;
992
993 /* BOLT #7:
994 * 1. type: 258 (`channel_update`)
995 * 2. data:
996 * * [`signature`:`signature`]
997 * * [`chain_hash`:`chain_hash`]
998 * * [`short_channel_id`:`short_channel_id`]
999 */
1000 /* Note that first two bytes are message type */
1001 const size_t update_scid_off = 2 + (64 + 32);
1002
1003 off += sizeof(struct gossip_hdr);
1004 /* For delete_chan scid immediately follows type */
1005 if (type == WIRE_GOSSIP_STORE_DELETE_CHAN)
1006 off += 2;
1007 else if (type == WIRE_GOSSIP_STORE_PRIVATE_UPDATE_OBS)
1008 /* Prepend header */
1009 off += 2 + 2 + update_scid_off;
1010 else if (type == WIRE_CHANNEL_UPDATE)
1011 off += update_scid_off;
1012 else
1013 abort();
1014
1015 if (pread(gosstore_fd, &raw, sizeof(raw), off) != sizeof(raw))
1016 return false;
1017 scid->u64 = be64_to_cpu(raw);
1018 return true;
1019}
1020
1021/* Note: this deletes up to two rows, one for each direction. */
1022static void delete_channel_from_db(struct command *cmd,

Callers 1

channels_refreshFunction · 0.85

Calls 2

abortFunction · 0.85
be64_to_cpuFunction · 0.85

Tested by

no test coverage detected