@Test public void testFeeForAtom() { PerBytesFeeEntry f = get(); assertEquals(UInt256.ZERO, f.feeFor(null, UNITS * THRESHOLD - 1, null)); assertEquals(UInt256.ZERO, f.feeFor(null, UNITS * THRESHOLD, null)); assertEquals(UInt256.ZERO, f.feeFor(null, UNITS * (THRESHOLD + 1) - 1, null)); assertEquals(FEE, f.feeFor(null, UNITS * (THRESHOLD + 1), null)); assertEquals(FEE.multiply(UInt256.TWO), f.feeFor(null, UNITS * (THRESHOLD + 2), null)); }
@Override public UInt256 feeFor(Atom a, int feeSize, Set<Particle> outputs) { long numberOfUnits = feeSize / this.units; if (numberOfUnits <= this.threshold) { return UInt256.ZERO; } long overThresholdUnits = numberOfUnits - this.threshold; UInt384 totalFee = UInt384.from(this.fee).multiply(UInt256.from(overThresholdUnits)); if (!totalFee.getHigh().isZero()) { throw new ArithmeticException("Fee overflow"); } return totalFee.getLow(); }
PerBytesFeeEntry implements FeeEntry { @Override public UInt256 feeFor(Atom a, int feeSize, Set<Particle> outputs) { long numberOfUnits = feeSize / this.units; if (numberOfUnits <= this.threshold) { return UInt256.ZERO; } long overThresholdUnits = numberOfUnits - this.threshold; UInt384 totalFee = UInt384.from(this.fee).multiply(UInt256.from(overThresholdUnits)); if (!totalFee.getHigh().isZero()) { throw new ArithmeticException("Fee overflow"); } return totalFee.getLow(); } }
PerBytesFeeEntry implements FeeEntry { @Override public UInt256 feeFor(Atom a, int feeSize, Set<Particle> outputs) { long numberOfUnits = feeSize / this.units; if (numberOfUnits <= this.threshold) { return UInt256.ZERO; } long overThresholdUnits = numberOfUnits - this.threshold; UInt384 totalFee = UInt384.from(this.fee).multiply(UInt256.from(overThresholdUnits)); if (!totalFee.getHigh().isZero()) { throw new ArithmeticException("Fee overflow"); } return totalFee.getLow(); } private  PerBytesFeeEntry(long units, long threshold, UInt256 fee); }
PerBytesFeeEntry implements FeeEntry { @Override public UInt256 feeFor(Atom a, int feeSize, Set<Particle> outputs) { long numberOfUnits = feeSize / this.units; if (numberOfUnits <= this.threshold) { return UInt256.ZERO; } long overThresholdUnits = numberOfUnits - this.threshold; UInt384 totalFee = UInt384.from(this.fee).multiply(UInt256.from(overThresholdUnits)); if (!totalFee.getHigh().isZero()) { throw new ArithmeticException("Fee overflow"); } return totalFee.getLow(); } private  PerBytesFeeEntry(long units, long threshold, UInt256 fee); static PerBytesFeeEntry of(long units, long threshold, UInt256 fee); long units(); long threshold(); UInt256 fee(); @Override UInt256 feeFor(Atom a, int feeSize, Set<Particle> outputs); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString(); }
PerBytesFeeEntry implements FeeEntry { @Override public UInt256 feeFor(Atom a, int feeSize, Set<Particle> outputs) { long numberOfUnits = feeSize / this.units; if (numberOfUnits <= this.threshold) { return UInt256.ZERO; } long overThresholdUnits = numberOfUnits - this.threshold; UInt384 totalFee = UInt384.from(this.fee).multiply(UInt256.from(overThresholdUnits)); if (!totalFee.getHigh().isZero()) { throw new ArithmeticException("Fee overflow"); } return totalFee.getLow(); } private  PerBytesFeeEntry(long units, long threshold, UInt256 fee); static PerBytesFeeEntry of(long units, long threshold, UInt256 fee); long units(); long threshold(); UInt256 fee(); @Override UInt256 feeFor(Atom a, int feeSize, Set<Particle> outputs); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString();  }