Add cumulative size to RPC block headers

This commit is contained in:
Zachary Michaels 2014-06-26 15:54:51 -04:00
parent f45b9efafd
commit 746af71727
4 changed files with 11 additions and 0 deletions

View File

@ -1055,6 +1055,11 @@ uint64_t blockchain_storage::block_cumulative_difficulty(size_t i)
return m_blocks[i].cumulative_difficulty; return m_blocks[i].cumulative_difficulty;
} }
//------------------------------------------------------------------ //------------------------------------------------------------------
uint64_t blockchain_storage::block_cumulative_size(size_t i)
{
return m_blocks[i].block_cumulative_size;
}
//------------------------------------------------------------------
uint64_t blockchain_storage::block_difficulty(size_t i) uint64_t blockchain_storage::block_difficulty(size_t i)
{ {
CRITICAL_REGION_LOCAL(m_blockchain_lock); CRITICAL_REGION_LOCAL(m_blockchain_lock);
@ -1093,6 +1098,7 @@ std::vector<block_header_responce> blockchain_storage::get_block_headers(uint64_
, reward , reward
, blk.tx_hashes.size() , blk.tx_hashes.size()
, block_info.cumulative_difficulty , block_info.cumulative_difficulty
, block_info.block_cumulative_size
); );
} }
} }

View File

@ -108,6 +108,7 @@ namespace cryptonote
uint64_t get_current_comulative_blocksize_limit(); uint64_t get_current_comulative_blocksize_limit();
bool is_storing_blockchain(){return m_is_blockchain_storing;} bool is_storing_blockchain(){return m_is_blockchain_storing;}
uint64_t block_cumulative_difficulty(size_t i); uint64_t block_cumulative_difficulty(size_t i);
uint64_t block_cumulative_size(size_t i);
uint64_t block_difficulty(size_t i); uint64_t block_difficulty(size_t i);
std::vector<block_header_responce> get_block_headers(uint64_t start_index, uint64_t end_index); std::vector<block_header_responce> get_block_headers(uint64_t start_index, uint64_t end_index);

View File

@ -18,6 +18,7 @@ namespace cryptonote {
uint64_t reward; uint64_t reward;
uint64_t tx_count; uint64_t tx_count;
uint64_t cumulative_difficulty; uint64_t cumulative_difficulty;
uint64_t cumulative_size;
block_header_responce() = default; block_header_responce() = default;
@ -35,6 +36,7 @@ namespace cryptonote {
, uint64_t reward , uint64_t reward
, uint64_t tx_count , uint64_t tx_count
, uint64_t cumulative_difficulty , uint64_t cumulative_difficulty
, uint64_t cumulative_size
) )
: major_version(major_version) : major_version(major_version)
, minor_version(minor_version) , minor_version(minor_version)
@ -49,6 +51,7 @@ namespace cryptonote {
, reward(reward) , reward(reward)
, tx_count(tx_count) , tx_count(tx_count)
, cumulative_difficulty(cumulative_difficulty) , cumulative_difficulty(cumulative_difficulty)
, cumulative_size(cumulative_size)
{} {}
BEGIN_KV_SERIALIZE_MAP() BEGIN_KV_SERIALIZE_MAP()

View File

@ -572,6 +572,7 @@ namespace cryptonote
responce.reward = get_block_reward(blk); responce.reward = get_block_reward(blk);
responce.tx_count = blk.tx_hashes.size(); responce.tx_count = blk.tx_hashes.size();
responce.cumulative_difficulty = m_core.get_blockchain_storage().block_cumulative_difficulty(height); responce.cumulative_difficulty = m_core.get_blockchain_storage().block_cumulative_difficulty(height);
responce.cumulative_size = m_core.get_blockchain_storage().block_cumulative_size(height);
return true; return true;
} }
//------------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------------