Skip to content

Commit

Permalink
Trivial: Minor cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
chris.orogvany committed Mar 14, 2018
1 parent 2db7af6 commit 1430200
Show file tree
Hide file tree
Showing 11 changed files with 33 additions and 23 deletions.
2 changes: 1 addition & 1 deletion config/semuxpool.properties
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ minPayoutSem = 0.25
# (leaving these as defaults is fine)
# #######################################

# To prevent whales from moving votes in after ensuring their validator state is guarenteed
# To prevent whales from moving votes in after ensuring their validator state is guaranteed
# We need to have a minimum age on votes before counting them.
minimumVoteAgeBeforeCounting = 200

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/semuxpool/pool/Pool.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class Pool implements Runnable
{
private static final Logger logger = LoggerFactory.getLogger(Pool.class);

private int loggingInterval;
private final int loggingInterval;
private final SemuxClient client;
private final Persistence persistence;
private final String delegateAddress;
Expand Down
8 changes: 1 addition & 7 deletions src/main/java/com/semuxpool/pool/PoolChecker.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,9 @@ public static void main(String[] args) throws IOException, SemuxException
}

//let's scan all blocks since beginning of time and see what's missing
Long totalBlocks = Long.valueOf(client.getInfo().getLatestBlockNumber());
Long totalBlocks = (long) client.getInfo().getLatestBlockNumber();
for(long i =0; i<= totalBlocks;i++)
{
if(i %10000 == 0)
{

}
Block block = client.getBlock(i);
if(block.getCoinbase().equals(delegateAddress))
{
Expand All @@ -71,7 +67,5 @@ public static void main(String[] args) throws IOException, SemuxException
}
}
}


}
}
7 changes: 5 additions & 2 deletions src/main/java/com/semuxpool/pool/PoolRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,11 @@ public static void main(String[] args) throws IOException, SemuxException
boolean debugMode = Boolean.valueOf(properties.getProperty("debugMode", "false"));
//handle pool quitters
boolean dontPayPoolQuitters = Boolean.valueOf(properties.getProperty("dontPayPoolQuitters", "false"));
String payQuitterAddress = properties.getProperty("poolQuitterAddress");
poolAddresses.add(payQuitterAddress);
String payQuitterAddress = properties.getProperty("poolQuitterAddress", "");
if(!payQuitterAddress.isEmpty())
{
poolAddresses.add(payQuitterAddress);
}
Integer minimumVoteAgeBeforeCounting = Integer.valueOf(properties.getProperty("minimumVoteAgeBeforeCounting", "200"));

PoolProfitAddresses poolProfitsAddress = PoolProfitAddresses.fromString(properties.getProperty("poolProfitsAddress"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public void registerValidator(String validatorAddress, float donationPercent, Se
}
}

public CloseableHttpClient getClient() throws KeyManagementException, NoSuchAlgorithmException
private CloseableHttpClient getClient() throws KeyManagementException, NoSuchAlgorithmException
{
SSLContext sslContext = SSLContext.getInstance("SSL");

Expand Down Expand Up @@ -113,9 +113,8 @@ public void checkServerTrusted(X509Certificate[] certs,
SchemeRegistry schemeRegistry = new SchemeRegistry();
schemeRegistry.register(httpsScheme);

// apache HttpClient version >4.2 should use BasicClientConnectionManager
// apache HttpClient version >4.2 should use BasicClientConnectionManager
ClientConnectionManager cm = new SingleClientConnManager(schemeRegistry);
CloseableHttpClient httpClient = HttpClients.custom().setSslcontext(sslContext).build();
return httpClient;
return HttpClients.custom().setSslcontext(sslContext).build();
}
}
2 changes: 2 additions & 0 deletions src/main/java/com/semuxpool/pool/api/Status.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

/**
* Pools current status
*
* TODO - WIP
*/
public class Status
{
Expand Down
20 changes: 16 additions & 4 deletions src/main/java/com/semuxpool/pool/block/BlockResultFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class BlockResultFactory
private final float poolPayoutPercent;
private final float donationPercent;
private final PoolProfitAddresses poolProfitsAddress;
private Integer minimumVoteAgeBeforeCounting;
private final Integer minimumVoteAgeBeforeCounting;
private final Long blockReward;
private Set<String> voterWhitelist = new HashSet<>();

Expand Down Expand Up @@ -118,7 +118,12 @@ public BlockResult getBlockResult(Block block) throws IOException, SemuxExceptio
//

//get payout for pool
Long poolPayout = result.getPayouts().get(poolProfitsAddress);

Long poolPayout = 0l;
for (String profitAddress : poolProfitsAddress.getAddresses())
{
poolPayout += result.getPayouts().get(profitAddress);
}
logger.trace("Pool profits: " + poolPayout);
float totalPercent = 0;
float totalVotesPercent = 0;
Expand Down Expand Up @@ -186,7 +191,7 @@ else if (transaction.getType().equals("UNVOTE"))

if (valueToAdd != 0L)
{
Long currentVal = (Long) votes.get(transaction.getFrom());
Long currentVal = votes.get(transaction.getFrom());
if (currentVal == null)
{
currentVal = 0L;
Expand All @@ -199,7 +204,14 @@ else if (transaction.getType().equals("UNVOTE"))
currentVal = 0l;
}

votes.put(transaction.getFrom(), currentVal);
if (currentVal > 0)
{
votes.put(transaction.getFrom(), currentVal);
}
else
{
votes.remove(transaction.getFrom());
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/semuxpool/pool/pay/PoolPayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class PoolPayer
//whether to count votes from voter's who left in the middle of the cycle
private final boolean dontPayPoolQuitters;
private final String payQuitterAddress;
private Set<String> poolAddresses;
private final Set<String> poolAddresses;

public PoolPayer(SemuxClient client, String delegateAddress, Persistence persistence, long fee,
long minPayout, String note, boolean dontPayPoolQuitters, String payQuitterAddress, Set<String> poolAddresses)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
public class PoolProfitAddresses
{
private static final Logger logger = LoggerFactory.getLogger(PoolProfitAddresses.class);
private Map<String, Float> addressToPercent = new HashMap<>();

private final Map<String, Float> addressToPercent = new HashMap<>();

public static PoolProfitAddresses fromString(String addresses)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class JsonPersistence implements Persistence
{
private static final Logger logger = LoggerFactory.getLogger(JsonPersistence.class);
private static final ObjectMapper MAPPER = new ObjectMapper();
private static String payoutsDirectory = "payouts";
private String payoutsDirectory = "payouts";

public JsonPersistence(String payoutsDirectory)
{
Expand Down
1 change: 0 additions & 1 deletion src/main/java/com/semuxpool/pool/state/PoolState.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.semuxpool.pool.Constants;
import com.semuxpool.pool.api.Payment;
import com.semuxpool.pool.api.Payout;
import com.semuxpool.pool.status.StatusLogger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down

0 comments on commit 1430200

Please sign in to comment.