-
Notifications
You must be signed in to change notification settings - Fork 114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unity integration - FixedPoint / BlockHeaderValidators #987
Conversation
f83471a
to
8cc7519
Compare
this.value = value; | ||
} | ||
|
||
public FixedPoint(BigDecimal value) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
package private
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also use the string directly, add comment
|
||
public BigDecimal toBigDecimal() { | ||
|
||
BigDecimal maxPrecision = new BigDecimal(BigInteger.ONE.shiftLeft(PRECISION)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use MAX_PRECISION directly
|
||
// This class can NOT be used for negative values | ||
|
||
public class FixedPoint { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Final
public static final FixedPoint ZERO = new FixedPoint(BigInteger.ZERO); | ||
public static final FixedPoint ONE = new FixedPoint(BigInteger.ONE.shiftLeft(PRECISION)); | ||
|
||
private BigInteger value; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Final
return multiplyInteger(BigInteger.valueOf(multiplicand)); | ||
} | ||
|
||
public FixedPoint divideInteger(BigInteger divisor) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove
// This test calculates the logs for all integers from 1 to 2^20, and records how many of them | ||
// end up with the same value. That is, it records how many x /= y satisfy log(x) = log(y) using our approximator | ||
@Test | ||
public void testCollisions() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -44,6 +47,7 @@ | |||
import org.aion.zero.impl.valid.AionExtraDataRule; | |||
import org.aion.zero.impl.valid.AionHeaderVersionRule; | |||
import org.aion.zero.impl.valid.EnergyConsumedRule; | |||
import org.aion.zero.impl.valid.EquihashSolutionRule; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove it
|
||
public void logErrors(final Logger logger, final List<RuleError> errors) { | ||
void logErrors(final Logger logger, final List<RuleError> errors) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
call it statically
@@ -3,12 +3,15 @@ | |||
import java.util.List; | |||
import org.aion.mcf.blockchain.BlockHeader; | |||
|
|||
public abstract class GrandParentDependantBlockHeaderRule | |||
extends AbstractValidRule { | |||
public abstract class GrandParentDependantBlockHeaderRule extends AbstractValidRule { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make it an interface
8cc7519
to
fc61a48
Compare
- FixedPoint represents non-integral numbers by multiplying them by a large power of 2. - LogApproximator approximates the natural log of integers using a shift-and-add algorithm. The returned value is a FixedPoint.
fc61a48
to
241877e
Compare
Notice
Please submit your PR to the
master
branch and rebase your code onmaster
before opening the pull request.Description
Please include a brief summary of the change that this pull request proposes. Include any relevant motivation and context. List any dependencies required for this change.
Fixes Issue # .
Type of change
Insert x into the following checkboxes to confirm (eg. [x]):
Testing
Please describe the tests you used to validate this pull request. Provide any relevant details for test configurations as well as any instructions to reproduce these results.