src/assetallocation.cpp
// keep track of average balance within the interest claim period
keep track of average balance within the interest claim period
keep track of average balance within the interest claim period
bool AccumulateInterestSinceLastClaim(CAssetAllocation & assetAllocation, const int& nHeight) {
	const int &nBlocksSinceLastUpdate = (nHeight - assetAllocation.nHeight);
	if (nBlocksSinceLastUpdate <= 0)
		return false;
	assetAllocation.nAccumulatedBalanceSinceLastInterestClaim += ((double)assetAllocation.nBalance)*nBlocksSinceLastUpdate;
	assetAllocation.fAccumulatedInterestSinceLastInterestClaim += assetAllocation.fInterestRate*nBlocksSinceLastUpdate;
	return true;
}
bool AccumulateInterestSinceLastClaim ( CAssetAllocation & assetAllocation , const int & nHeight ) { const int & nBlocksSinceLastUpdate = ( nHeight - assetAllocation . nHeight ) ; if ( nBlocksSinceLastUpdate <= 0 ) return false ; assetAllocation . nAccumulatedBalanceSinceLastInterestClaim += ( ( double ) assetAllocation . nBalance ) * nBlocksSinceLastUpdate ; assetAllocation . fAccumulatedInterestSinceLastInterestClaim += assetAllocation . fInterestRate * nBlocksSinceLastUpdate ; return true ; }
keep track of average balance within the interest claim period
keep track of average balance within the interest claim period
// formula is 1/N * (blocks since last update * previous balance/interest rate) where N is the number of blocks in the total time period