Commit d22e1757 authored by zeroleak's avatar zeroleak
Browse files

set minerFeeMix=mustMixMin*minerFeeMin

parent 12359738
......@@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>io.samourai.code.whirlpool</groupId>
<artifactId>whirlpool-server</artifactId>
<version>0.23.13</version>
<version>develop-SNAPSHOT</version>
<name>whirlpool-server</name>
<properties>
<spring-boot.version>2.1.6.RELEASE</spring-boot.version>
......
......@@ -109,7 +109,7 @@ public class Mix {
}
// verify minerFeeMix
if (computeMinerFeeAccumulated() < minerFeeConfig.getMinerFeeMix()) {
if (computeMinerFeeAccumulated() < pool.getMinerFeeMix()) {
return false;
}
return true;
......
......@@ -11,6 +11,7 @@ public class Pool {
private int minLiquidity;
private int anonymitySet;
private WhirlpoolServerConfig.MinerFeeConfig minerFeeConfig;
private long minerFeeMix;
private Mix currentMix;
private InputPool mustMixQueue;
......@@ -23,7 +24,8 @@ public class Pool {
int minMustMix,
int minLiquidity,
int anonymitySet,
WhirlpoolServerConfig.MinerFeeConfig minerFeeConfig) {
WhirlpoolServerConfig.MinerFeeConfig minerFeeConfig,
long minerFeeMix) {
this.poolId = poolId;
this.denomination = denomination;
this.poolFee = poolFee;
......@@ -31,6 +33,7 @@ public class Pool {
this.minLiquidity = minLiquidity;
this.anonymitySet = anonymitySet;
this.minerFeeConfig = minerFeeConfig;
this.minerFeeMix = minerFeeMix;
this.mustMixQueue = new InputPool();
this.liquidityQueue = new InputPool();
......@@ -93,6 +96,10 @@ public class Pool {
return anonymitySet;
}
public long getMinerFeeMix() {
return minerFeeMix;
}
public Mix getCurrentMix() {
return currentMix;
}
......
......@@ -372,6 +372,10 @@ public class WhirlpoolServerConfig extends ServerConfig {
public void setAnonymitySet(int anonymitySet) {
this.anonymitySet = anonymitySet;
}
public long getMinerFeeMix(MinerFeeConfig minerFeeConfig) {
return mustMixMin * minerFeeConfig.getMinerFeeMin();
}
}
public static class RpcClientConfig {
......@@ -509,10 +513,6 @@ public class WhirlpoolServerConfig extends ServerConfig {
public void setMinerFeeMax(long minerFeeMax) {
this.minerFeeMax = minerFeeMax;
}
public long getMinerFeeMix() {
return minerFeeMin * 2;
}
}
public static class ScodeSamouraiFeeConfig {
......@@ -613,8 +613,7 @@ public class WhirlpoolServerConfig extends ServerConfig {
+ minerFees.getMinerFeeCap()
+ ", max="
+ minerFees.getMinerFeeMax()
+ "], mix="
+ minerFees.getMinerFeeMix());
+ "]");
configInfo.put(
"registerInput.maxInputsSameHash", String.valueOf(registerInput.maxInputsSameHash));
......@@ -662,7 +661,8 @@ public class WhirlpoolServerConfig extends ServerConfig {
+ poolConfig.getMustMixMin()
+ ", liquidityMin="
+ poolConfig.getLiquidityMin()
+ "]";
+ "], minerFeeMix="
+ poolConfig.getMinerFeeMix(minerFees);
configInfo.put("pools[" + poolConfig.id + "]", poolInfo);
}
int i = 0;
......
......@@ -62,6 +62,7 @@ public class StatusWebController {
poolAttributes.put("anonymitySet", pool.getAnonymitySet());
poolAttributes.put("minMustMix", pool.getMinMustMix());
poolAttributes.put("minLiquidity", pool.getMinLiquidity());
poolAttributes.put("minerFeeMix", pool.getMinerFeeMix());
poolAttributes.put("minerFeeAccumulated", mix.computeMinerFeeAccumulated());
poolAttributes.put("nbInputs", mix.getNbInputs());
poolAttributes.put("nbInputsMustMix", mix.getNbInputsMustMix());
......@@ -129,7 +130,6 @@ public class StatusWebController {
minerFees.put("minerFeeMin", serverConfig.getMinerFees().getMinerFeeMin());
minerFees.put("minerFeeCap", serverConfig.getMinerFees().getMinerFeeCap());
minerFees.put("minerFeeMax", serverConfig.getMinerFees().getMinerFeeMax());
minerFees.put("minerFeeMix", serverConfig.getMinerFees().getMinerFeeMix());
model.addAttribute("minerFees", minerFees);
return "status";
}
......
......@@ -135,9 +135,7 @@ public class MixService {
if (liquiditySlotsAvailable == pool.getMinLiquidity()) {
long inputMinerFees = registeredInput.computeMinerFees(pool);
long minerFeeAccumulated = mix.computeMinerFeeAccumulated();
long missingMinerFees =
whirlpoolServerConfig.getMinerFees().getMinerFeeMix()
- (minerFeeAccumulated + inputMinerFees);
long missingMinerFees = pool.getMinerFeeMix() - (minerFeeAccumulated + inputMinerFees);
if (missingMinerFees > 0) {
logMixStatus(mix);
log.warn(
......@@ -413,7 +411,7 @@ public class MixService {
+ " anonymitySet, "
+ mix.computeMinerFeeAccumulated()
+ "/"
+ whirlpoolServerConfig.getMinerFees().getMinerFeeMix()
+ mix.getPool().getMinerFeeMix()
+ "sat (pool: "
+ liquiditiesQueued
+ " liquidities + "
......
......@@ -74,6 +74,7 @@ public class PoolService {
int minMustMix = poolConfig.getMustMixMin();
int minLiquidity = poolConfig.getLiquidityMin();
int anonymitySet = poolConfig.getAnonymitySet();
long minerFeeMix = poolConfig.getMinerFeeMix(minerFeeConfig);
Assert.notNull(poolId, "Pool configuration: poolId must not be NULL");
Assert.isTrue(!pools.containsKey(poolId), "Pool configuration: poolId must not be duplicate");
......@@ -86,7 +87,8 @@ public class PoolService {
minMustMix,
minLiquidity,
anonymitySet,
minerFeeConfig);
minerFeeConfig,
minerFeeMix);
pools.put(poolId, pool);
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment