Skip to content
This repository has been archived by the owner on Aug 23, 2020. It is now read-only.

Make PearlDiver threads configurable #1017

Merged
merged 1 commit into from
Nov 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion src/main/java/com/iota/iri/conf/BaseIotaConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ public abstract class BaseIotaConfig implements IotaConfig {
protected double alpha = Defaults.ALPHA;
private int maxAnalyzedTransactions = Defaults.MAX_ANALYZED_TXS;

//PearlDiver
protected int powThreads = Defaults.POW_THREADS;

//Snapshot
protected boolean localSnapshotsEnabled = Defaults.LOCAL_SNAPSHOTS_ENABLED;
protected boolean localSnapshotsPruningEnabled = Defaults.LOCAL_SNAPSHOTS_PRUNING_ENABLED;
Expand Down Expand Up @@ -676,6 +679,17 @@ protected void setBelowMaxDepthTransactionLimit(int maxAnalyzedTransactions) {
this.maxAnalyzedTransactions = maxAnalyzedTransactions;
}

@Override
public int getPowThreads() {
return powThreads;
}

@JsonProperty
@Parameter(names = "--pow-threads", description = PearlDiverConfig.Descriptions.POW_THREADS)
protected void setPowThreads(int powThreads) {
this.powThreads = powThreads;
}

public interface Defaults {
//API
int API_PORT = 14265;
Expand Down Expand Up @@ -732,6 +746,9 @@ public interface Defaults {
int MAX_DEPTH = 15;
double ALPHA = 0.001d;

//PearlDiver
int POW_THREADS = 0;

//Coo
String COORDINATOR_ADDRESS =
"KPWCHICGJZXKE9GSUDXZYUAPLHAKAHYHDXNPHENTERYMMBQOPSQIDENXKLKCEYCPVTZQLEEJVYJZV9BWU";
Expand All @@ -753,4 +770,4 @@ public interface Defaults {
int NUM_KEYS_IN_MILESTONE = 20;
int MAX_ANALYZED_TXS = 20_000;
}
}
}
2 changes: 1 addition & 1 deletion src/main/java/com/iota/iri/conf/IotaConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* In charge of how we parse the configuration from given inputs.
*/
public interface IotaConfig extends APIConfig, NodeConfig,
IXIConfig, DbConfig, ConsensusConfig, ZMQConfig, TipSelConfig {
IXIConfig, DbConfig, ConsensusConfig, ZMQConfig, TipSelConfig, PearlDiverConfig {
File CONFIG_FILE = new File("iota.ini");

/**
Expand Down
19 changes: 19 additions & 0 deletions src/main/java/com/iota/iri/conf/PearlDiverConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.iota.iri.conf;

/**
* Configurations for PearlDiver proof-of-work hasher.
*/
public interface PearlDiverConfig extends Config {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer PowConfig

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Er, you originally asked for PearlDiverConfig. I think that's more appropriate, as there may be other config fields added later.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍


/**
* @return {@value PearlDiverConfig.Descriptions#POW_THREADS}
*/
int getPowThreads();

/**
* Field descriptions
*/
interface Descriptions {
String POW_THREADS = "Number of threads to use for proof-of-work calculation";
}
}
2 changes: 1 addition & 1 deletion src/main/java/com/iota/iri/service/API.java
Original file line number Diff line number Diff line change
Expand Up @@ -1099,7 +1099,7 @@ public synchronized List<String> attachToTangleStatement(final Hash trunkTransac
Converter.copyTrits(MAX_TIMESTAMP_VALUE,transactionTrits,TransactionViewModel.ATTACHMENT_TIMESTAMP_UPPER_BOUND_TRINARY_OFFSET,
TransactionViewModel.ATTACHMENT_TIMESTAMP_UPPER_BOUND_TRINARY_SIZE);

if (!pearlDiver.search(transactionTrits, minWeightMagnitude, 0)) {
if (!pearlDiver.search(transactionTrits, minWeightMagnitude, instance.configuration.getPowThreads())) {
transactionViewModels.clear();
break;
}
Expand Down