# BOLT #7 types, see https://github.com/lightning/bolts/blob/master/07-routing-gossip.md
MSG_TYPE_CHANNEL_ANNOUNCEMENT = 256
MSG_TYPE_NODE_ANNOUNCEMENT = 257
MSG_TYPE_CHANNEL_UPDATE = 258

# Core Lightning internal messages
MSG_TYPE_CHANNEL_AMOUNT = 4101
MSG_TYPE_PRIVATE_CHANNEL_UPDATE = 4102
MSG_TYPE_DELETE_CHANNEL = 4103
MSG_TYPE_PRIVATE_CHANNEL_ANNOUNCEMENT = 4104
MSG_TYPE_GOSSIP_STORE_ENDED = 4105
MSG_TYPE_CHANNEL_DYING = 4106

# Type name map
GOSSIP_TYPE_NAMES = {
    MSG_TYPE_CHANNEL_ANNOUNCEMENT: "channel_announcement",
    MSG_TYPE_NODE_ANNOUNCEMENT: "node_announcement",
    MSG_TYPE_CHANNEL_UPDATE: "channel_update",
    MSG_TYPE_CHANNEL_AMOUNT: "channel_amount",
    MSG_TYPE_PRIVATE_CHANNEL_UPDATE: "private_update",
    MSG_TYPE_DELETE_CHANNEL: "delete_channel",
    MSG_TYPE_PRIVATE_CHANNEL_ANNOUNCEMENT: "private_channel",
    MSG_TYPE_GOSSIP_STORE_ENDED: "ended",
    MSG_TYPE_CHANNEL_DYING: "channel_dying",
}

LIGHTNING_TYPES = {
    MSG_TYPE_CHANNEL_ANNOUNCEMENT,
    MSG_TYPE_NODE_ANNOUNCEMENT,
    MSG_TYPE_CHANNEL_UPDATE,
}

CORE_LIGHTNING_TYPES = {
    MSG_TYPE_CHANNEL_AMOUNT,
    MSG_TYPE_PRIVATE_CHANNEL_UPDATE,
    MSG_TYPE_DELETE_CHANNEL,
    MSG_TYPE_PRIVATE_CHANNEL_ANNOUNCEMENT,
    MSG_TYPE_GOSSIP_STORE_ENDED,
    MSG_TYPE_CHANNEL_DYING,
}

# Header format
HEADER_FORMAT = ">HHII"  # flags(2) + len(2) + crc(4) + timestamp(4)

ALL_TYPES = set(CORE_LIGHTNING_TYPES) | set(LIGHTNING_TYPES)
