mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-22 08:34:20 +01:00
gossmap: make API more robust against future changes.
Many changes to gossmap (including the pending ones!) don't actually concern readers, as long as they obey certain rules: 1. Ignore unknown messages. 2. Treat all 16 upper bits of length as flags, ignore unknown ones. So now we split the version byte into MAJOR and MINOR, and you can ignore MINOR changes. We don't expose the internal version (for creating the map) programmatically: you should really hardcode what major version you understand! Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -155,7 +155,7 @@ int main(int argc, char *argv[])
|
||||
} else
|
||||
outfd = STDOUT_FILENO;
|
||||
|
||||
version = GOSSIP_STORE_VERSION;
|
||||
version = ((0 << 5) | 10);
|
||||
if (!write_all(outfd, &version, sizeof(version)))
|
||||
err(1, "Writing version");
|
||||
|
||||
|
||||
@@ -10,6 +10,10 @@
|
||||
#include <unistd.h>
|
||||
#include <wire/peer_wire.h>
|
||||
|
||||
/* Current versions we support */
|
||||
#define GSTORE_MAJOR 0
|
||||
#define GSTORE_MINOR 10
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int fd;
|
||||
@@ -43,11 +47,19 @@ int main(int argc, char *argv[])
|
||||
if (read(fd, &version, sizeof(version)) != sizeof(version))
|
||||
errx(1, "Empty file");
|
||||
|
||||
if (version != GOSSIP_STORE_VERSION)
|
||||
warnx("UNSUPPORTED GOSSIP VERSION %u (expected %u)",
|
||||
version, GOSSIP_STORE_VERSION);
|
||||
if (GOSSIP_STORE_MAJOR_VERSION(version) != GSTORE_MAJOR)
|
||||
errx(1, "Unsupported major gossip_version %u (expected %u)",
|
||||
GOSSIP_STORE_MAJOR_VERSION(version), GSTORE_MAJOR);
|
||||
|
||||
printf("GOSSIP VERSION %u\n", version);
|
||||
/* Unsupported minor just means we might not understand all fields,
|
||||
* or all flags. */
|
||||
if (GOSSIP_STORE_MINOR_VERSION(version) != GSTORE_MINOR)
|
||||
warnx("UNKNOWN GOSSIP minor VERSION %u (expected %u)",
|
||||
GOSSIP_STORE_MINOR_VERSION(version), GSTORE_MINOR);
|
||||
|
||||
printf("GOSSIP VERSION %u/%u\n",
|
||||
GOSSIP_STORE_MINOR_VERSION(version),
|
||||
GOSSIP_STORE_MAJOR_VERSION(version));
|
||||
off = 1;
|
||||
|
||||
while (read(fd, &hdr, sizeof(hdr)) == sizeof(hdr)) {
|
||||
|
||||
Reference in New Issue
Block a user