diff --git a/graftlets/rta/requests/getsupernodeinfo.cpp b/graftlets/rta/requests/getsupernodeinfo.cpp index f3078c7b..53c62e55 100644 --- a/graftlets/rta/requests/getsupernodeinfo.cpp +++ b/graftlets/rta/requests/getsupernodeinfo.cpp @@ -69,7 +69,7 @@ Status handleSupernodeInfoRequest(const Router::vars_t &vars, const Input &input FullSupernodeList::blockchain_based_list auth_sample_base_list; uint64_t bbl_block_height = fsl->getBlockchainBasedListMaxBlockNumber(); - uint64_t auth_sample_base_block_number = fsl->getBlockchainBasedListForAuthSample(bbl_block_height, auth_sample_base_list); + uint64_t auth_sample_base_block_number = fsl->getBlockchainBasedListForHeight(bbl_block_height, auth_sample_base_list); auto is_supernode_available = [&](const std::string& supernode_public_id) { diff --git a/include/rta/fullsupernodelist.h b/include/rta/fullsupernodelist.h index c0ece09e..f5331c50 100644 --- a/include/rta/fullsupernodelist.h +++ b/include/rta/fullsupernodelist.h @@ -194,7 +194,7 @@ class FullSupernodeList * \param out_list - resulting list * \return - block number which was used for base list */ - uint64_t getBlockchainBasedListForAuthSample(uint64_t block_number, blockchain_based_list& list) const; + uint64_t getBlockchainBasedListForHeight(uint64_t block_number, blockchain_based_list& list) const; /*! * \brief synchronizeWithCryptonode - synchronize with cryptonode diff --git a/src/apps/rta-wallet-cli/main.cpp b/src/apps/rta-wallet-cli/main.cpp index 15c40b96..52576c44 100644 --- a/src/apps/rta-wallet-cli/main.cpp +++ b/src/apps/rta-wallet-cli/main.cpp @@ -333,7 +333,25 @@ class Wallet abort(); } - + // test ptx + { + std::string ptx_blob = tools::wallet2::pending_tx::serialize(m_ptx_v.at(0)); + tools::wallet2::pending_tx test_ptx; + + if (!tools::wallet2::pending_tx::deserialize(ptx_blob, test_ptx)) { + MERROR("Failed to deserialize ptx"); + abort(); + } + if (cryptonote::get_transaction_hash(test_ptx.tx) + != tx.hash) { + + MERROR("original and serialized transactions mismatch: " + << "original hash: " << tx.hash << ", deserialized hash: " + << cryptonote::get_transaction_hash(test_ptx.tx) + << "original tx: " << cryptonote::obj_to_json_str(m_ptx_v.at(0).tx) + << "deserialized tx: " << cryptonote::obj_to_json_str(test_ptx.tx)); + } + } PayRequest pay_req; diff --git a/src/rta/fullsupernodelist.cpp b/src/rta/fullsupernodelist.cpp index 528dca01..432823e6 100644 --- a/src/rta/fullsupernodelist.cpp +++ b/src/rta/fullsupernodelist.cpp @@ -277,18 +277,18 @@ bool FullSupernodeList::selectSupernodes(size_t items_count, const std::string& return true; } -uint64_t FullSupernodeList::getBlockchainBasedListForAuthSample(uint64_t block_number, blockchain_based_list& list) const +uint64_t FullSupernodeList::getBlockchainBasedListForHeight(uint64_t block_height, blockchain_based_list& list) const { boost::shared_lock readerLock(m_access); - uint64_t blockchain_based_list_height = block_number; + uint64_t blockchain_based_list_height = block_height; - if (block_number == 0) { - block_number = this->getBlockchainBasedListMaxBlockNumber(); - blockchain_based_list_height = block_number - BLOCKCHAIN_BASED_LIST_DELAY_BLOCK_COUNT; + if (block_height == 0) { + block_height = this->getBlockchainBasedListMaxBlockNumber(); + blockchain_based_list_height = block_height - BLOCKCHAIN_BASED_LIST_DELAY_BLOCK_COUNT; } - blockchain_based_list_map::const_iterator it = m_blockchain_based_lists.find(block_number); + blockchain_based_list_map::const_iterator it = m_blockchain_based_lists.find(block_height); if (it == m_blockchain_based_lists.end()) return 0; @@ -344,7 +344,7 @@ bool FullSupernodeList::buildAuthSample(uint64_t height, const std::string& paym blockchain_based_list bbl; - out_auth_block_number = getBlockchainBasedListForAuthSample(height, bbl); + out_auth_block_number = getBlockchainBasedListForHeight(height, bbl); if (!out_auth_block_number) { @@ -359,14 +359,13 @@ bool FullSupernodeList::buildAuthSample(uint64_t height, const std::string& paym { boost::unique_lock writerLock(m_access); - //seed RNG - + // seed RNG std::seed_seq seed(reinterpret_cast(payment_id.c_str()), reinterpret_cast(payment_id.c_str() + payment_id.size())); m_rng.seed(seed); - //select supernodes for a full supernode list + //select supernodes for a full supernode list MDEBUG("use blockchain based list for height " << out_auth_block_number); int t = 1; diff --git a/src/supernode/requests/debug.cpp b/src/supernode/requests/debug.cpp index 8d5e4b28..07c4a9f2 100644 --- a/src/supernode/requests/debug.cpp +++ b/src/supernode/requests/debug.cpp @@ -61,7 +61,7 @@ Status getSupernodeList(const Router::vars_t& vars, const graft::Input& input, FullSupernodeList::blockchain_based_list auth_sample_base_list; - uint64_t auth_sample_base_block_number = fsl->getBlockchainBasedListForAuthSample(resp.result.height, auth_sample_base_list); + uint64_t auth_sample_base_block_number = fsl->getBlockchainBasedListForHeight(resp.result.height, auth_sample_base_list); auto is_supernode_available = [&](const std::string& supernode_public_id) { @@ -248,7 +248,7 @@ Status getBlockchainBasedListImpl(const Router::vars_t& vars, const graft::Input switch (mode) { case BlockchainBasedListMode_ForAuthSample: - resp.result.Height = fsl->getBlockchainBasedListForAuthSample(block_height, bbl); + resp.result.Height = fsl->getBlockchainBasedListForHeight(block_height, bbl); if (!resp.result.Height) {