mirror of
				https://github.com/0glabs/0g-chain.git
				synced 2025-11-04 03:47:39 +00:00 
			
		
		
		
	fix: account for start time in calculating time elapsed (#821)
This commit is contained in:
		
							parent
							
								
									fe2a131b31
								
							
						
					
					
						commit
						7e39c1d0a8
					
				@ -642,10 +642,16 @@ func (k Keeper) ZeroHardLiquidityProviderClaim(ctx sdk.Context, claim types.Hard
 | 
			
		||||
// CalculateTimeElapsed calculates the number of reward-eligible seconds that have passed since the previous
 | 
			
		||||
// time rewards were accrued, taking into account the end time of the reward period
 | 
			
		||||
func CalculateTimeElapsed(start, end, blockTime time.Time, previousAccrualTime time.Time) sdk.Int {
 | 
			
		||||
	if end.Before(blockTime) &&
 | 
			
		||||
		(end.Before(previousAccrualTime) || end.Equal(previousAccrualTime)) {
 | 
			
		||||
	if (end.Before(blockTime) &&
 | 
			
		||||
		(end.Before(previousAccrualTime) || end.Equal(previousAccrualTime))) ||
 | 
			
		||||
		(start.After(previousAccrualTime)) ||
 | 
			
		||||
		(start.Equal(blockTime)) {
 | 
			
		||||
		return sdk.ZeroInt()
 | 
			
		||||
	}
 | 
			
		||||
	if start.After(previousAccrualTime) && start.Before(blockTime) {
 | 
			
		||||
		previousAccrualTime = start
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if end.Before(blockTime) {
 | 
			
		||||
		return sdk.NewInt(int64(math.RoundToEven(
 | 
			
		||||
			end.Sub(previousAccrualTime).Seconds(),
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user