MCPcopy Create free account
hub / github.com/bcndev/bytecoin / on_getblocktemplate

Method on_getblocktemplate

src/Core/NodeLegacyAPI.cpp:86–112  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

84}
85
86bool Node::on_getblocktemplate(http::Client *who, http::RequestBody &&raw_request, json_rpc::Request &&raw_js_request,
87 api::cnd::GetBlockTemplate::Request &&req, api::cnd::GetBlockTemplate::Response &res) {
88 if (!m_config.good_bytecoind_auth_private(raw_request.r.basic_authorization))
89 throw http::ErrorAuthorization("authorization-private");
90 api::cnd::GetStatus::Request sta;
91 sta.top_block_hash = req.top_block_hash;
92 sta.transaction_pool_version = req.transaction_pool_version;
93 api::cnd::GetStatus::Response status_res = create_status_response();
94 m_log(logging::INFO) << "Node received getblocktemplate REQ transaction_pool_version="
95 << (req.transaction_pool_version ? common::to_string(req.transaction_pool_version.get())
96 : "empty")
97 << " top_block_hash="
98 << (req.top_block_hash ? common::pod_to_hex(req.top_block_hash.get()) : "empty");
99 m_log(logging::INFO) << "Node received getblocktemplate CUR transaction_pool_version="
100 << m_block_chain.get_tx_pool_version() << " top_block_hash=" << m_block_chain.get_tip_bid();
101 if (!status_res.ready_for_longpoll(sta)) {
102 LongPollClient lpc;
103 lpc.original_who = who;
104 lpc.original_request = raw_request;
105 lpc.original_json_request = std::move(raw_js_request);
106 lpc.original_get_status = sta;
107 m_long_poll_http_clients.push_back(lpc);
108 return false;
109 }
110 getblocktemplate(req, res);
111 return true;
112}
113
114void Node::getblocktemplate(const api::cnd::GetBlockTemplate::Request &req, api::cnd::GetBlockTemplate::Response &res) {
115 if (req.reserve_size > extra::Nonce::MAX_COUNT)

Callers

nothing calls this directly

Calls 8

ErrorAuthorizationClass · 0.85
pod_to_hexFunction · 0.85
ready_for_longpollMethod · 0.80
to_stringFunction · 0.50
getMethod · 0.45
get_tx_pool_versionMethod · 0.45
get_tip_bidMethod · 0.45

Tested by

no test coverage detected