Skip to content

Commit

Permalink
Fixed Ethash events firing
Browse files Browse the repository at this point in the history
  • Loading branch information
zilm13 committed Jun 13, 2018
1 parent cb5f167 commit 6488ed5
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions ethereumj-core/src/main/java/org/ethereum/mine/Ethash.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,14 @@ public Ethash(SystemProperties config, long blockNumber) {
}
}

public int[] getCacheLight() {
fireDatatasetStatusUpdate(DATASET_PREPARE);
int[] res = getCacheLightImpl();
fireDatatasetStatusUpdate(DATASET_READY);
return res;
public synchronized int[] getCacheLight() {
if (cacheLight == null) {
fireDatatasetStatusUpdate(DATASET_PREPARE);
getCacheLightImpl();
fireDatatasetStatusUpdate(DATASET_READY);
}

return cacheLight;
}

/**
Expand Down Expand Up @@ -168,8 +171,8 @@ private synchronized int[] getCacheLightImpl() {
}

public synchronized int[] getFullDataset() {
fireDatatasetStatusUpdate(DATASET_PREPARE);
if (fullData == null) {
fireDatatasetStatusUpdate(DATASET_PREPARE);
File file = new File(config.ethashDir(), "mine-dag.dat");
if (fileCacheEnabled && file.canRead()) {
fireDatatasetStatusUpdate(FULL_DATASET_LOAD_START);
Expand Down Expand Up @@ -208,8 +211,8 @@ public synchronized int[] getFullDataset() {
}
fireDatatasetStatusUpdate(FULL_DATASET_GENERATED);
}
fireDatatasetStatusUpdate(DATASET_READY);
}
fireDatatasetStatusUpdate(DATASET_READY);
return fullData;
}

Expand Down

0 comments on commit 6488ed5

Please sign in to comment.