Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add block hash to blockchain_based_list request from cryptonode to supernode #279

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/cryptonote_core/stake_transaction_processor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,12 @@ void StakeTransactionProcessor::invoke_update_blockchain_based_list_handler_impl
uint64_t height = m_blockchain_based_list->block_height();

for (size_t i=0; i<depth; i++)
m_on_blockchain_based_list_update(height - i, m_blockchain_based_list->tiers(i));
{
uint64_t block_height = height - i;
crypto::hash block_hash = m_blockchain.get_block_id_by_height(block_height);

m_on_blockchain_based_list_update(block_height, block_hash, m_blockchain_based_list->tiers(i));
}

m_blockchain_based_list_need_update = false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/cryptonote_core/stake_transaction_processor.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class StakeTransactionProcessor
void invoke_update_stakes_handler(bool force = true);

typedef BlockchainBasedList::supernode_tier_array supernode_tier_array;
typedef std::function<void(uint64_t block_number, const supernode_tier_array&)> blockchain_based_list_update_handler;
typedef std::function<void(uint64_t block_number, const crypto::hash& block_hash, const supernode_tier_array&)> blockchain_based_list_update_handler;

/// Update handler for new blockchain based list
void set_on_update_blockchain_based_list_handler(const blockchain_based_list_update_handler&);
Expand Down
2 changes: 1 addition & 1 deletion src/p2p/net_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ namespace nodetool

private:
void handle_stakes_update(uint64_t block_number, const cryptonote::StakeTransactionProcessor::supernode_stake_array& stakes);
void handle_blockchain_based_list_update(uint64_t block_number, const cryptonote::StakeTransactionProcessor::supernode_tier_array& tiers);
void handle_blockchain_based_list_update(uint64_t block_number, const crypto::hash& block_hash, const cryptonote::StakeTransactionProcessor::supernode_tier_array& tiers);

private:
std::multimap<int, std::string> m_supernode_requests_timestamps;
Expand Down
5 changes: 3 additions & 2 deletions src/p2p/net_node.inl
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ namespace nodetool
);

m_payload_handler.get_core().set_update_blockchain_based_list_handler(
[&](uint64_t block_height, const cryptonote::StakeTransactionProcessor::supernode_tier_array& tiers) { handle_blockchain_based_list_update(block_height, tiers); }
[&](uint64_t block_height, const crypto::hash& block_hash, const cryptonote::StakeTransactionProcessor::supernode_tier_array& tiers) { handle_blockchain_based_list_update(block_height, block_hash, tiers); }
);

std::set<std::string> full_addrs;
Expand Down Expand Up @@ -2974,7 +2974,7 @@ namespace nodetool
}

template<class t_payload_net_handler>
void node_server<t_payload_net_handler>::handle_blockchain_based_list_update(uint64_t block_height, const cryptonote::StakeTransactionProcessor::supernode_tier_array& tiers)
void node_server<t_payload_net_handler>::handle_blockchain_based_list_update(uint64_t block_height, const crypto::hash& block_hash, const cryptonote::StakeTransactionProcessor::supernode_tier_array& tiers)
{
static std::string supernode_endpoint("blockchain_based_list");

Expand All @@ -2988,6 +2988,7 @@ namespace nodetool
cryptonote::COMMAND_RPC_SUPERNODE_BLOCKCHAIN_BASED_LIST::request request;

request.block_height = block_height;
request.block_hash = epee::string_tools::pod_to_hex(block_hash);

for (size_t i=0; i<tiers.size(); i++)
{
Expand Down
2 changes: 2 additions & 0 deletions src/rpc/core_rpc_server_commands_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -1813,9 +1813,11 @@ namespace cryptonote
struct request
{
uint64_t block_height;
std::string block_hash;
std::vector<tier> tiers;
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(block_height)
KV_SERIALIZE(block_hash)
KV_SERIALIZE(tiers)
END_KV_SERIALIZE_MAP()
};
Expand Down