From c1f93f58ee401804c3aca0e19c668fd4b3dee398 Mon Sep 17 00:00:00 2001 From: Meheboob Khan Date: Mon, 26 Sep 2022 20:14:31 +0000 Subject: [PATCH] Added functionality to check if the device size is less than 50 MB [Issue 389] --- libraries/chain/db_block.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libraries/chain/db_block.cpp b/libraries/chain/db_block.cpp index 9606c59e..65f10cc7 100644 --- a/libraries/chain/db_block.cpp +++ b/libraries/chain/db_block.cpp @@ -40,8 +40,10 @@ #include #include #include +#include #include +#include namespace { @@ -196,6 +198,9 @@ bool database::push_block(const signed_block& new_block, uint32_t skip) bool database::_push_block(const signed_block& new_block) { try { + boost::filesystem::space_info si = boost::filesystem::space(get_data_dir()); + FC_ASSERT((si.available) > 104857600, "Rejecting block due to low disk space"); // 104857600 bytes = 100 MB + uint32_t skip = get_node_properties().skip_flags; const auto now = fc::time_point::now().sec_since_epoch(); @@ -726,7 +731,7 @@ void database::_apply_block( const signed_block& next_block ) check_ending_lotteries(); check_ending_nft_lotteries(); - + create_block_summary(next_block); place_delayed_bets(); // must happen after update_global_dynamic_data() updates the time clear_expired_transactions();