Skip to content

Commit

Permalink
renamed getBlockchainBasedListForAuthSample/
Browse files Browse the repository at this point in the history
getBlockchainBasedListForHeight
  • Loading branch information
mbg033 committed Aug 4, 2020
1 parent d7d36f8 commit 632f921
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 15 deletions.
2 changes: 1 addition & 1 deletion graftlets/rta/requests/getsupernodeinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion include/rta/fullsupernodelist.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 19 additions & 1 deletion src/apps/rta-wallet-cli/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
19 changes: 9 additions & 10 deletions src/rta/fullsupernodelist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<boost::shared_mutex> 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;
Expand Down Expand Up @@ -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)
{
Expand All @@ -359,14 +359,13 @@ bool FullSupernodeList::buildAuthSample(uint64_t height, const std::string& paym
{
boost::unique_lock<boost::shared_mutex> writerLock(m_access);

//seed RNG

// seed RNG
std::seed_seq seed(reinterpret_cast<const unsigned char*>(payment_id.c_str()),
reinterpret_cast<const unsigned char*>(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;
Expand Down
4 changes: 2 additions & 2 deletions src/supernode/requests/debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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)
{
Expand Down

0 comments on commit 632f921

Please sign in to comment.