@@ -145,7 +145,7 @@ UniValue rpc_getblockstats(const UniValue& params, bool fHelp)
145145 c_version[claim.m_client_version ]++;
146146 researchtotal += claim.m_research_subsidy ;
147147 interesttotal += claim.m_block_subsidy ;
148- researchcount += ( claim.m_research_subsidy > 10000 ); // 0.001
148+ researchcount += claim.HasResearchReward ();
149149 minttotal+=cur->nMint ;
150150 unsigned sizeblock = GetSerializeSize (block, SER_NETWORK, PROTOCOL_VERSION);
151151 size_min_blk=std::min (size_min_blk,sizeblock);
@@ -191,13 +191,22 @@ UniValue rpc_getblockstats(const UniValue& params, bool fHelp)
191191 }
192192 {
193193 UniValue result (UniValue::VOBJ);
194- result.pushKV (" research" , ValueFromAmount (researchtotal / researchcount));
194+
195+ // check for zero researchcount and if so make research_average 0.
196+ int64_t research_average = researchcount ? researchtotal / researchcount : 0 ;
197+
198+ result.pushKV (" research" , ValueFromAmount (research_average));
195199 result.pushKV (" interest" , ValueFromAmount (interesttotal / blockcount));
196200 result.pushKV (" mint" , ValueFromAmount (minttotal / blockcount));
197201 // result.pushKV("stake_input", (stakeinputtotal/(double)poscount)/(double)COIN);
198202 result.pushKV (" spacing_sec" , ((double )l_last_time-(double )l_first_time)/(double )blockcount);
199203 result.pushKV (" block_per_day" , ((double )blockcount*86400.0 )/((double )l_last_time-(double )l_first_time));
200- result.pushKV (" transaction" , transactioncount/(double )(blockcount-emptyblockscount));
204+
205+ // check for zero blockcount-emptyblockscount and if so make transaction average 0.
206+ double transaction_average = (blockcount - emptyblockscount) ?
207+ transactioncount / (double ) (blockcount - emptyblockscount) : 0 ;
208+
209+ result.pushKV (" transaction" , transaction_average);
201210 result.pushKV (" blocksizek" , size_sum_blk/(double )blockcount/(double )1024 );
202211 result.pushKV (" posdiff" , diff_sum/(double )poscount);
203212 if (super_count > 0 )
0 commit comments