1
0
Fork 0
forked from lthn/blockchain

minor improvements

This commit is contained in:
sowle 2022-10-20 18:28:47 +02:00
parent 8077c3e892
commit a1d39ad051
No known key found for this signature in database
GPG key ID: C07A24B2D89D49FC
6 changed files with 18 additions and 12 deletions

View file

@ -5463,7 +5463,8 @@ bool blockchain_storage::validate_pos_block(const block& b,
uint8_t err = 0;
r = crypto::zarcanum_verify_proof(miner_tx_hash, kernel_hash, ring, last_pow_block_id_hashed, stake_input.k_image, sig, &err);
CHECK_AND_ASSERT_MES(r, false, "zarcanum_verify_proof failed with code " << err);
final_diff = basic_diff; // just for logs
return true;
}
else
@ -5748,7 +5749,7 @@ bool blockchain_storage::handle_block_to_main_chain(const block& bl, const crypt
m_is_in_checkpoint_zone = false;
crypto::hash proof_hash = null_hash;
uint64_t pos_coinstake_amount = 0;
uint64_t pos_coinstake_amount = UINT64_MAX;
wide_difficulty_type this_coin_diff = 0;
bool is_pos_bl = is_pos_block(bl);
//check if PoS allowed in this height
@ -6094,7 +6095,12 @@ bool blockchain_storage::handle_block_to_main_chain(const block& bl, const crypt
{ // PoS
int64_t actual_ts = get_block_datetime(bei.bl); // signed int is intentionally used here
int64_t ts_diff = actual_ts - m_core_runtime_config.get_core_time();
powpos_str_entry << "PoS:\t" << proof_hash << ", stake amount: " << print_money_brief(pos_coinstake_amount) << ", final_difficulty: " << this_coin_diff;
powpos_str_entry << "PoS:\t" << proof_hash << ", stake amount: ";
if (pos_coinstake_amount != UINT64_MAX)
powpos_str_entry << print_money_brief(pos_coinstake_amount);
else
powpos_str_entry << "hidden";
powpos_str_entry << ", final_difficulty: " << this_coin_diff;
timestamp_str_entry << ", actual ts: " << actual_ts << " (diff: " << std::showpos << ts_diff << "s) block ts: " << std::noshowpos << bei.bl.timestamp << " (shift: " << std::showpos << static_cast<int64_t>(bei.bl.timestamp) - actual_ts << ")";
}
else

View file

@ -332,6 +332,9 @@ namespace currency
bool is_tx_expired(const transaction& tx) const;
std::shared_ptr<const transaction_chain_entry> find_key_image_and_related_tx(const crypto::key_image& ki, crypto::hash& id_result) const;
// returns true as soon as the hardfork is active for the NEXT upcoming block (not for the top block in the blockchain storage)
bool is_hardfork_active(size_t hardfork_id) const;
wide_difficulty_type block_difficulty(size_t i)const;
bool forecast_difficulty(std::vector<std::pair<uint64_t, wide_difficulty_type>> &out_height_2_diff_vector, bool pos) const;
bool prune_aged_alt_blocks();
@ -676,10 +679,6 @@ namespace currency
bool is_output_allowed_for_input(const txout_htlc& out_v, const txin_v& in_v, uint64_t top_minus_source_height)const;
bool is_output_allowed_for_input(const tx_out_zarcanum& out, const txin_v& in_v) const;
// returns true as soon as the hardfork is active for the NEXT upcoming block (not for the top block in the blockchain storage)
bool is_hardfork_active(size_t hardfork_id) const;
//POS

View file

@ -129,8 +129,9 @@ namespace currency
return boost::get<specific_type_t>(ai);
}
}
ASSERT_MES_AND_THROW("Objec not found");
ASSERT_MES_AND_THROW("Object with type " << typeid(specific_type_t).name() << " was not found in a container");
}
//---------------------------------------------------------------
// if cb returns true, it means "continue", false -- means "stop"
template<typename specific_type_t, typename variant_container_t, typename callback_t>
bool process_type_in_variant_container(const variant_container_t& av, callback_t& cb, bool return_value_if_none_found = true)

View file

@ -3168,7 +3168,7 @@ bool wallet2::generate_packing_transaction_if_needed(currency::transaction& tx,
//----------------------------------------------------------------------------------------------------
std::string wallet2::get_transfers_str(bool include_spent /*= true*/, bool include_unspent /*= true*/) const
{
static const char* header = "index amount g_index flags block tx out# key image";
static const char* header = "index amount g_index flags block tx out# key image";
std::stringstream ss;
ss << header << ENDL;
size_t count = 0;
@ -4379,7 +4379,7 @@ void wallet2::dump_trunsfers(std::stringstream& ss, bool verbose) const
else
{
boost::io::ios_flags_saver ifs(ss);
ss << "index amount spent_h g_index block block_ts flg tx out# key image" << ENDL;
ss << "index amount spent_h g_index block block_ts flg tx out# key image" << ENDL;
for (size_t i = 0; i != m_transfers.size(); i++)
{
const transfer_details& td = m_transfers[i];

View file

@ -699,7 +699,7 @@ namespace tools
bool fill_mining_context(mining_context& ctx);
void get_transfers(wallet2::transfer_container& incoming_transfers) const;
std::string get_transfers_str(bool include_spent /*= true*/, bool include_unspent /*= true*/) const;
std::string get_transfers_str(bool include_spent = true, bool include_unspent = true) const;
// Returns all payments by given id in unspecified order
void get_payments(const std::string& payment_id, std::list<payment_details>& payments, uint64_t min_height = 0) const;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2014-2018 Zano Project
// Copyright (c) 2014-2022 Zano Project
// Copyright (c) 2014-2018 The Louisdor Project
// Copyright (c) 2012-2013 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying