aboutsummaryrefslogtreecommitdiff
path: root/src/blockchain_db/lmdb
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2018-06-17 22:07:15 +0100
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2018-06-20 23:48:37 +0100
commite5592c4bab058e154f68858dcb41eed6c2f0f18a (patch)
tree7cd30dddbddb990145c0f2d9a48e9a2509ea2da4 /src/blockchain_db/lmdb
parentMerge pull request #3939 (diff)
downloadmonero-e5592c4bab058e154f68858dcb41eed6c2f0f18a.tar.xz
rpc: add blockchain disk size to getinfo
This should help new nodes predict how much disk space will be needed for a full sync
Diffstat (limited to 'src/blockchain_db/lmdb')
-rw-r--r--src/blockchain_db/lmdb/db_lmdb.cpp11
-rw-r--r--src/blockchain_db/lmdb/db_lmdb.h2
2 files changed, 13 insertions, 0 deletions
diff --git a/src/blockchain_db/lmdb/db_lmdb.cpp b/src/blockchain_db/lmdb/db_lmdb.cpp
index fe31321f3..be450dec0 100644
--- a/src/blockchain_db/lmdb/db_lmdb.cpp
+++ b/src/blockchain_db/lmdb/db_lmdb.cpp
@@ -35,6 +35,7 @@
#include <random>
#include "string_tools.h"
+#include "file_io_utils.h"
#include "common/util.h"
#include "cryptonote_basic/cryptonote_format_utils.h"
#include "crypto/crypto.h"
@@ -3422,6 +3423,16 @@ bool BlockchainLMDB::is_read_only() const
return false;
}
+uint64_t BlockchainLMDB::get_database_size() const
+{
+ uint64_t size = 0;
+ boost::filesystem::path datafile(m_folder);
+ datafile /= CRYPTONOTE_BLOCKCHAINDATA_FILENAME;
+ if (!epee::file_io_utils::get_file_size(datafile.string(), size))
+ size = 0;
+ return size;
+}
+
void BlockchainLMDB::fixup()
{
LOG_PRINT_L3("BlockchainLMDB::" << __func__);
diff --git a/src/blockchain_db/lmdb/db_lmdb.h b/src/blockchain_db/lmdb/db_lmdb.h
index cc1b06ca0..d1fb534a2 100644
--- a/src/blockchain_db/lmdb/db_lmdb.h
+++ b/src/blockchain_db/lmdb/db_lmdb.h
@@ -375,6 +375,8 @@ private:
virtual bool is_read_only() const;
+ virtual uint64_t get_database_size() const;
+
// fix up anything that may be wrong due to past bugs
virtual void fixup();