forked from lthn/blockchain
attempt to fix bug with unreturned key_images to tx_pool on reorganize
This commit is contained in:
parent
a609f6b974
commit
18c35f2274
5 changed files with 108 additions and 7 deletions
|
|
@ -3459,7 +3459,10 @@ bool blockchain_storage::have_tx_keyimges_as_spent(const transaction &tx) const
|
|||
if (in.type() == typeid(txin_to_key))
|
||||
{
|
||||
if (have_tx_keyimg_as_spent(boost::get<const txin_to_key>(in).k_image))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
else if (in.type() == typeid(txin_multisig))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@
|
|||
#define BASE_REWARD_DUST_THRESHOLD ((uint64_t)1000000) // pow(10, 6) - change this will cause hard-fork!
|
||||
#define DEFAULT_DUST_THRESHOLD ((uint64_t)0)//((uint64_t)100000) // pow(10, 5)
|
||||
|
||||
#define TX_DEFAULT_FEE ((uint64_t)100000) // pow(10, 5)
|
||||
#define TX_DEFAULT_FEE ((uint64_t)10000000000) // pow(10, 5)
|
||||
#define TX_MINIMUM_FEE ((uint64_t)100000) // pow(10, 5)
|
||||
|
||||
// #define CURRENCY_FIXED_REWARD_ZONE_HEIGHT 300 // blocks will have fixed reward up to this height (including)
|
||||
|
|
|
|||
|
|
@ -777,16 +777,14 @@ namespace currency
|
|||
//---------------------------------------------------------------------------------
|
||||
bool tx_memory_pool::on_tx_add(const transaction& tx, bool kept_by_block)
|
||||
{
|
||||
if (!kept_by_block)
|
||||
insert_key_images(tx, kept_by_block); // take into account only key images from txs that are not 'kept_by_block'
|
||||
insert_key_images(tx, kept_by_block);
|
||||
insert_alias_info(tx);
|
||||
return true;
|
||||
}
|
||||
//---------------------------------------------------------------------------------
|
||||
bool tx_memory_pool::on_tx_remove(const transaction& tx, bool kept_by_block)
|
||||
{
|
||||
if (!kept_by_block)
|
||||
remove_key_images(tx, kept_by_block); // take into account only key images from txs that are not 'kept_by_block'
|
||||
remove_key_images(tx, kept_by_block);
|
||||
remove_alias_info(tx);
|
||||
return true;
|
||||
}
|
||||
|
|
@ -944,8 +942,11 @@ namespace currency
|
|||
}
|
||||
}
|
||||
//if we here, transaction seems valid, but, anyway, check for key_images collisions with blockchain, just to be sure
|
||||
if(m_blockchain.have_tx_keyimges_as_spent(txd.tx))
|
||||
if (m_blockchain.have_tx_keyimges_as_spent(txd.tx))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if (!check_tx_multisig_ins_and_outs(txd.tx, false))
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
#include "crypto/hash.h"
|
||||
#include "warnings.h"
|
||||
#include "currency_core/bc_offers_service.h"
|
||||
#include "serialization/binary_utils.h"
|
||||
|
||||
PUSH_WARNINGS
|
||||
DISABLE_VS_WARNINGS(4100)
|
||||
|
|
@ -64,6 +65,8 @@ public:
|
|||
m_cmd_binder.set_handler("rescan_aliases", boost::bind(&daemon_cmmands_handler::rescan_aliases, this, _1), "Debug function");
|
||||
m_cmd_binder.set_handler("forecast_difficulty", boost::bind(&daemon_cmmands_handler::forecast_difficulty, this, _1), "Prints PoW and PoS difficulties for as many future blocks as possible based on current conditions");
|
||||
m_cmd_binder.set_handler("print_deadlock_guard", boost::bind(&daemon_cmmands_handler::print_deadlock_guard, this, _1), "Print all threads which is blocked or involved in mutex ownership");
|
||||
m_cmd_binder.set_handler("print_block_from_hex_blob", boost::bind(&daemon_cmmands_handler::print_block_from_hex_blob, this, _1), "Unserialize block from hex binary data to json-like representation");
|
||||
m_cmd_binder.set_handler("print_tx_from_hex_blob", boost::bind(&daemon_cmmands_handler::print_tx_from_hex_blob, this, _1), "Unserialize transaction from hex binary data to json-like representation");
|
||||
}
|
||||
|
||||
bool start_handling()
|
||||
|
|
@ -356,6 +359,101 @@ private:
|
|||
return true;
|
||||
}
|
||||
//--------------------------------------------------------------------------------
|
||||
template<class t_item>
|
||||
bool print_t_from_hex_blob(const std::string& item_hex_blob)
|
||||
{
|
||||
std::string bin_buff;
|
||||
bool res = epee::string_tools::parse_hexstr_to_binbuff(item_hex_blob, bin_buff);
|
||||
CHECK_AND_ASSERT_MES(res, false, "failed to parse hex");
|
||||
|
||||
t_item item = AUTO_VAL_INIT(item);
|
||||
|
||||
res = ::serialization::parse_binary(bin_buff, item);
|
||||
CHECK_AND_ASSERT_MES(res, false, "failed to parse binary");
|
||||
|
||||
|
||||
LOG_PRINT_L0("OBJECT " << typeid(item).name() << ": " << ENDL << obj_to_json_str(item));
|
||||
return true;
|
||||
}
|
||||
//--------------------------------------------------------------------------------
|
||||
bool print_block_from_hex_blob(const std::vector<std::string>& args)
|
||||
{
|
||||
if (!args.size())
|
||||
{
|
||||
std::cout << "need block blob parameter" << ENDL;
|
||||
return false;
|
||||
}
|
||||
|
||||
print_t_from_hex_blob<currency::block>(args[0]);
|
||||
|
||||
LOG_PRINT_GREEN("Done", LOG_LEVEL_0);
|
||||
return true;
|
||||
}
|
||||
//--------------------------------------------------------------------------------
|
||||
bool print_tx_from_hex_blob(const std::vector<std::string>& args)
|
||||
{
|
||||
if (!args.size())
|
||||
{
|
||||
std::cout << "need block blob parameter" << ENDL;
|
||||
return false;
|
||||
}
|
||||
|
||||
print_t_from_hex_blob<currency::transaction>(args[0]);
|
||||
|
||||
LOG_PRINT_GREEN("Done", LOG_LEVEL_0);
|
||||
return true;
|
||||
}
|
||||
//--------------------------------------------------------------------------------
|
||||
struct tx_pool_exported_blobs
|
||||
{
|
||||
std::list<currency::tx_rpc_extended_info> all_txs_details;
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(all_txs_details)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
//--------------------------------------------------------------------------------
|
||||
bool export_tx_pool_to_json(const std::vector<std::string>& args)
|
||||
{
|
||||
// if (!args.size())
|
||||
// {
|
||||
// std::cout << "need block blob parameter" << ENDL;
|
||||
// return false;
|
||||
// }
|
||||
// tx_pool_exported_blobs tx_pool_json;
|
||||
// m_srv.get_payload_object().get_core().get_tx_pool().get_all_transactions_details(tx_pool_json.all_txs_details);
|
||||
// std::string pool_state = epee::serialization::store_t_to_json(tx_pool_json);
|
||||
// CHECK_AND_ASSERT_THROW(pool_state.size(), false, "Unable to export pool");
|
||||
//
|
||||
// bool r = file_io_utils::save_string_to_file(args[0], pool_state);
|
||||
// CHECK_AND_ASSERT_THROW(r, false, "Unable to export pool");
|
||||
// LOG_PRINT_GREEN("Exported OK(" << tx_pool_json.all_txs_details.size() <<" transactions)");
|
||||
return true;
|
||||
}
|
||||
//--------------------------------------------------------------------------------
|
||||
bool import_tx_pool_to_json(const std::vector<std::string>& args)
|
||||
{
|
||||
// if (!args.size())
|
||||
// {
|
||||
// std::cout << "need block blob parameter" << ENDL;
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// std::string buff;
|
||||
// bool r = file_io_utils::load_file_to_string(args[0], buff);
|
||||
//
|
||||
// tx_pool_exported_blobs tx_pool_json;
|
||||
//
|
||||
//
|
||||
// m_srv.get_payload_object().get_core().get_tx_pool().get_all_transactions_details(tx_pool_json.all_txs_details);
|
||||
// std::string pool_state = epee::serialization::store_t_to_json(tx_pool_json);
|
||||
// CHECK_AND_ASSERT_THROW(pool_state.size(), false, "Unable to export pool");
|
||||
//
|
||||
//
|
||||
// CHECK_AND_ASSERT_THROW(r, false, "Unable to export pool");
|
||||
// LOG_PRINT_GREEN("Exported OK(" << tx_pool_json.all_txs_details.size() << " transactions)");
|
||||
return true;
|
||||
}
|
||||
//--------------------------------------------------------------------------------
|
||||
bool print_bci(const std::vector<std::string>& args)
|
||||
{
|
||||
m_srv.get_payload_object().get_core().print_blockchain_index();
|
||||
|
|
|
|||
|
|
@ -905,7 +905,6 @@ bool simple_wallet::get_transfer_info(const std::vector<std::string> &args)
|
|||
{
|
||||
fail_msg_writer() << "failed to find transfer info by key_image";
|
||||
return true;
|
||||
|
||||
}
|
||||
}
|
||||
std::string json_details = epee::serialization::store_t_to_json(td);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue