-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #147 from ltonetwork/juicy-fix-fork
Fix for JUICY fork when synced from genesis
- Loading branch information
Showing
7 changed files
with
47 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.ltonetwork.utils | ||
|
||
trait Fraction { | ||
def apply(l: Long): Long; | ||
} | ||
|
||
object Fraction { | ||
private case class RoundDownFraction(dividend: Int, divider: Int) extends Fraction { | ||
def apply(l: Long): Long = l / divider * dividend | ||
} | ||
|
||
private case class RoundUpFraction(dividend: Int, divider: Int) extends Fraction { | ||
private val inv = RoundDownFraction(divider - dividend, divider) | ||
def apply(l: Long): Long = l - inv(l) | ||
} | ||
|
||
def roundDown(dividend: Int, divider: Int): Fraction = RoundDownFraction(dividend, divider) | ||
def roundUp(dividend: Int, divider: Int): Fraction = RoundUpFraction(dividend, divider) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters