ignore bws sync requests until initial sync is complete (#6455)

* ignore bws sync requests until initial sync is complete
* return failed Future when BWS is invoked but not ready

Signed-off-by: garyschulte <garyschulte@gmail.com>
pull/6466/head
garyschulte 10 months ago committed by GitHub
parent 4ac32c6df9
commit ed1480ba33
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 26
      ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/backwardsync/BackwardSyncContext.java

@ -129,12 +129,16 @@ public class BackwardSyncContext {
backwardChain.addNewHash(newBlockHash);
}
final Status status = getOrStartSyncSession();
backwardChain
.getBlock(newBlockHash)
.ifPresent(
newTargetBlock -> status.updateTargetHeight(newTargetBlock.getHeader().getNumber()));
return status.currentFuture;
if (isReady()) {
final Status status = getOrStartSyncSession();
backwardChain
.getBlock(newBlockHash)
.ifPresent(
newTargetBlock -> status.updateTargetHeight(newTargetBlock.getHeader().getNumber()));
return status.currentFuture;
} else {
return CompletableFuture.failedFuture(new Throwable("Backward sync is not ready"));
}
}
public synchronized CompletableFuture<Void> syncBackwardsUntil(final Block newPivot) {
@ -142,9 +146,13 @@ public class BackwardSyncContext {
backwardChain.appendTrustedBlock(newPivot);
}
final Status status = getOrStartSyncSession();
status.updateTargetHeight(newPivot.getHeader().getNumber());
return status.currentFuture;
if (isReady()) {
final Status status = getOrStartSyncSession();
status.updateTargetHeight(newPivot.getHeader().getNumber());
return status.currentFuture;
} else {
return CompletableFuture.failedFuture(new Throwable("Backward sync is not ready"));
}
}
private Status getOrStartSyncSession() {

Loading…
Cancel
Save