From 67d11ced309ec854cdb974e5c66648ab9d7a2e61 Mon Sep 17 00:00:00 2001 From: Doug Hoyte Date: Tue, 7 Feb 2023 08:19:13 -0500 Subject: [PATCH] output DB version in info command --- src/cmd_info.cpp | 13 +++++++++++++ src/constants.h | 1 + src/onAppStartup.cpp | 3 ++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/cmd_info.cpp b/src/cmd_info.cpp index 835e22b..df9b9cd 100644 --- a/src/cmd_info.cpp +++ b/src/cmd_info.cpp @@ -23,5 +23,18 @@ void cmd_info(const std::vector &subArgs) { auto txn = env.txn_ro(); + uint64_t dbVersion; + + { + auto s = env.lookup_Meta(txn, 1); + + if (s) { + dbVersion = s->dbVersion(); + } else { + dbVersion = 0; + } + } + + std::cout << "DB version: " << dbVersion << "\n"; std::cout << "merkle root: " << to_hex(qdb.root(txn)) << "\n"; } diff --git a/src/constants.h b/src/constants.h index 831e58f..6cd8bca 100644 --- a/src/constants.h +++ b/src/constants.h @@ -1,4 +1,5 @@ #pragma once +const uint64_t CURR_DB_VERSION = 1; const size_t MAX_SUBID_SIZE = 71; // Statically allocated size in SubId const uint64_t MAX_TIMESTAMP = 17179869184; // Safety limit to ensure it can fit in quadrable key. Good until year 2514. diff --git a/src/onAppStartup.cpp b/src/onAppStartup.cpp index 26e810d..a5cc4f6 100644 --- a/src/onAppStartup.cpp +++ b/src/onAppStartup.cpp @@ -5,7 +5,8 @@ #include "golpe.h" -const size_t CURR_DB_VERSION = 1; +#include "constants.h" + static void dbCheck(lmdb::txn &txn, const std::string &cmd) { auto dbTooOld = [&](uint64_t ver) {