Skip to content

Commit

Permalink
delegate next view logic to the current Committee
Browse files Browse the repository at this point in the history
  • Loading branch information
Hellblazer committed Mar 7, 2024
1 parent 75fdaab commit 19d7f16
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
32 changes: 29 additions & 3 deletions choam/src/main/java/com/salesforce/apollo/choam/CHOAM.java
Original file line number Diff line number Diff line change
Expand Up @@ -306,9 +306,15 @@ public String logState() {
* @param diadem - the compact HexBloom of the context view
*/
public void nextView(Context<Member> context, Digest diadem) {
pendingView.set(new PendingView(context, diadem));
params.context().setContext(context);
this.diadem.set(diadem);
var c = current.get();
var pv = new PendingView(context, diadem);
if (c != null) {
c.nextView(pv);
} else {
params.context().setContext(context);
this.diadem.set(diadem);
CHOAM.this.pendingView.set(pv);
}
}

public void setDiadem(Digest diadem) {
Expand Down Expand Up @@ -1173,6 +1179,11 @@ public Logger log() {
return log;
}

@Override
public void nextView(PendingView pendingView) {
CHOAM.this.pendingView.set(pendingView);
}

@Override
public Parameters params() {
return params;
Expand Down Expand Up @@ -1329,6 +1340,13 @@ public Logger log() {
return log;
}

@Override
public void nextView(PendingView pendingView) {
params.context().setContext(pendingView.context);
CHOAM.this.diadem.set(pendingView.diadem);
CHOAM.this.pendingView.set(pendingView);
}

@Override
public Parameters params() {
return params;
Expand All @@ -1354,6 +1372,7 @@ public boolean validate(HashedCertifiedBlock hb) {

/** a synchronizer of the current committee */
private class Synchronizer implements Committee {

private final Map<Member, Verifier> validators;

public Synchronizer(Map<Member, Verifier> validators) {
Expand Down Expand Up @@ -1384,6 +1403,13 @@ public Logger log() {
return log;
}

@Override
public void nextView(PendingView pendingView) {
params.context().setContext(pendingView.context);
CHOAM.this.diadem.set(pendingView.diadem);
CHOAM.this.pendingView.set(pendingView);
}

@Override
public Parameters params() {
return params;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ default void assembled() {

Logger log();

void nextView(CHOAM.PendingView pendingView);

Parameters params();

default void regenerate() {
Expand Down

0 comments on commit 19d7f16

Please sign in to comment.