Skip to content

Commit

Permalink
remove unused
Browse files Browse the repository at this point in the history
  • Loading branch information
Hellblazer committed Feb 7, 2024
1 parent 3d600d1 commit 30b9dbd
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 90 deletions.
80 changes: 0 additions & 80 deletions ethereal/src/main/java/com/salesforce/apollo/ethereal/Checks.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,73 @@

import com.salesforce.apollo.ethereal.Dag.DagImpl;

import java.util.function.BiFunction;

/**
* @author hal.hildebrand
*
*/
public interface DagFactory {
public class DefaultChecksFactory implements DagFactory {
static BiFunction<Unit, Dag, Correctness> parentConsistency() {
return (unit, dag) -> {
var parents = unit.parents();
var nproc = dag.nProc();
for (short i = 0; i < nproc; i++) {
for (short j = 0; j < nproc; j++) {
if (parents[j] == null) {
continue;
}
var u = parents[j].parents()[i];
if (u != null && (parents[i] == null || parents[i].level() < u.level())) {
return Correctness.COMPLIANCE_ERROR;
}
}
}
return null;
};
}

static BiFunction<Unit, Dag, Correctness> basicCorrectness() {
return (u, dag) -> {
var parents = u.parents();
var nproc = dag.nProc();
if (parents.length != nproc) {
return Correctness.COMPLIANCE_ERROR;
}
short nonNillParents = 0;
for (short i = 0; i < nproc; i++) {
if (parents[i] == null) {
continue;
}
nonNillParents++;
if (parents[i].creator() != i) {
return Correctness.COMPLIANCE_ERROR;
}
}
if (u.predecessor() == null && nonNillParents > 0) {
return Correctness.COMPLIANCE_ERROR;
}
if (u.predecessor() != null && u.predecessor().level() >= u.level()) {
return Correctness.COMPLIANCE_ERROR;
}
return null;
};
}

Dag createDag(short nProc);

class DefaultChecksFactory implements DagFactory {

@Override
public Dag createDag(short nProc) {
var cnf = Config.newBuilder().setnProc(nProc).build();
var dag = new DagImpl(cnf, 0);
dag.addCheck(Checks.basicCorrectness());
dag.addCheck(Checks.parentConsistency());
dag.addCheck(Checks.noSelfForkingEvidence());
dag.addCheck(Checks.forkerMuting());

dag.addCheck(basicCorrectness());
dag.addCheck(parentConsistency());
return dag;
}
}

public class TestDagFactory implements DagFactory {
class TestDagFactory implements DagFactory {

private final int initialEpoch;

Expand All @@ -46,6 +92,4 @@ public Dag createDag(short nProc) {
return new DagImpl(cnf, initialEpoch);
}
}

Dag createDag(short nProc);
}

0 comments on commit 30b9dbd

Please sign in to comment.