From 19d7f1667867bf6f7133e1b15837fc3212ad1216 Mon Sep 17 00:00:00 2001 From: Hellblazer Date: Wed, 6 Mar 2024 18:59:28 -0800 Subject: [PATCH] delegate next view logic to the current Committee --- .../com/salesforce/apollo/choam/CHOAM.java | 32 +++++++++++++++++-- .../salesforce/apollo/choam/Committee.java | 2 ++ 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/choam/src/main/java/com/salesforce/apollo/choam/CHOAM.java b/choam/src/main/java/com/salesforce/apollo/choam/CHOAM.java index c7f65a8c1..eea506548 100644 --- a/choam/src/main/java/com/salesforce/apollo/choam/CHOAM.java +++ b/choam/src/main/java/com/salesforce/apollo/choam/CHOAM.java @@ -306,9 +306,15 @@ public String logState() { * @param diadem - the compact HexBloom of the context view */ public void nextView(Context 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) { @@ -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; @@ -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; @@ -1354,6 +1372,7 @@ public boolean validate(HashedCertifiedBlock hb) { /** a synchronizer of the current committee */ private class Synchronizer implements Committee { + private final Map validators; public Synchronizer(Map validators) { @@ -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; diff --git a/choam/src/main/java/com/salesforce/apollo/choam/Committee.java b/choam/src/main/java/com/salesforce/apollo/choam/Committee.java index fb8ddd80c..97317dec0 100644 --- a/choam/src/main/java/com/salesforce/apollo/choam/Committee.java +++ b/choam/src/main/java/com/salesforce/apollo/choam/Committee.java @@ -73,6 +73,8 @@ default void assembled() { Logger log(); + void nextView(CHOAM.PendingView pendingView); + Parameters params(); default void regenerate() {