Skip to content

Commit

Permalink
little spotless and javadoc
Browse files Browse the repository at this point in the history
Signed-off-by: garyschulte <[email protected]>
  • Loading branch information
garyschulte committed Dec 6, 2023
1 parent b0db11d commit 7c1da83
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 21 deletions.
5 changes: 5 additions & 0 deletions besu/src/main/java/org/hyperledger/besu/Runner.java
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,11 @@ Optional<EnodeURL> getLocalEnode() {
return networkRunner.getNetwork().getLocalEnode();
}

/**
* get p2p network
*
* @return P2PNetwork
*/
public P2PNetwork getP2PNetwork() {
return networkRunner.getNetwork();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,10 @@ public SynchronizationServiceImpl(
this.protocolContext = protocolContext;
this.protocolSchedule = protocolSchedule;
this.syncState = syncState;
this.worldStateArchive = Optional.ofNullable(worldStateArchive)
.filter(z -> z instanceof BonsaiWorldStateProvider)
.map(BonsaiWorldStateProvider.class::cast);
this.worldStateArchive =
Optional.ofNullable(worldStateArchive)
.filter(z -> z instanceof BonsaiWorldStateProvider)
.map(BonsaiWorldStateProvider.class::cast);
}

@Override
Expand Down Expand Up @@ -102,9 +103,7 @@ public boolean setHeadUnsafe(final BlockHeader blockHeader, final BlockBody bloc

final MutableBlockchain blockchain = protocolContext.getBlockchain();

if (worldStateArchive
.flatMap(archive -> archive.getMutable(coreHeader, true))
.isPresent()) {
if (worldStateArchive.flatMap(archive -> archive.getMutable(coreHeader, true)).isPresent()) {
if (coreHeader.getParentHash().equals(blockchain.getChainHeadHash())) {
LOG.atDebug()
.setMessage(
Expand All @@ -131,20 +130,22 @@ public boolean isInitialSyncPhaseDone() {
@Override
public void disableWorldStateTrie() {
// TODO MAYBE FIND A BEST WAY TO DELETE AND DISABLE TRIE
worldStateArchive.ifPresent(archive -> {
archive.getDefaultBonsaiWorldStateConfig().setTrieDisabled(true);
final BonsaiWorldStateKeyValueStorage worldStateStorage = archive.getWorldStateStorage();
final Optional<Hash> worldStateBlockHash = worldStateStorage.getWorldStateBlockHash();
final Optional<Bytes> worldStateRootHash = worldStateStorage.getWorldStateRootHash();
if (worldStateRootHash.isPresent() && worldStateBlockHash.isPresent()) {
worldStateStorage.clearTrie();
// keep root and block hash in the trie branch
final BonsaiWorldStateKeyValueStorage.BonsaiUpdater updater = worldStateStorage.updater();
updater.saveWorldState(worldStateBlockHash.get(), Bytes32.wrap(worldStateRootHash.get()),
Bytes.EMPTY);
updater.commit();
worldStateStorage.upgradeToFullFlatDbMode();
}
});
worldStateArchive.ifPresent(
archive -> {
archive.getDefaultBonsaiWorldStateConfig().setTrieDisabled(true);
final BonsaiWorldStateKeyValueStorage worldStateStorage = archive.getWorldStateStorage();
final Optional<Hash> worldStateBlockHash = worldStateStorage.getWorldStateBlockHash();
final Optional<Bytes> worldStateRootHash = worldStateStorage.getWorldStateRootHash();
if (worldStateRootHash.isPresent() && worldStateBlockHash.isPresent()) {
worldStateStorage.clearTrie();
// keep root and block hash in the trie branch
final BonsaiWorldStateKeyValueStorage.BonsaiUpdater updater =
worldStateStorage.updater();
updater.saveWorldState(
worldStateBlockHash.get(), Bytes32.wrap(worldStateRootHash.get()), Bytes.EMPTY);
updater.commit();
worldStateStorage.upgradeToFullFlatDbMode();
}
});
}
}

0 comments on commit 7c1da83

Please sign in to comment.