Skip to content

Commit 7c1da83

Browse files
committed
little spotless and javadoc
Signed-off-by: garyschulte <garyschulte@gmail.com>
1 parent b0db11d commit 7c1da83

File tree

2 files changed

+27
-21
lines changed

2 files changed

+27
-21
lines changed

besu/src/main/java/org/hyperledger/besu/Runner.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,11 @@ Optional<EnodeURL> getLocalEnode() {
423423
return networkRunner.getNetwork().getLocalEnode();
424424
}
425425

426+
/**
427+
* get p2p network
428+
*
429+
* @return P2PNetwork
430+
*/
426431
public P2PNetwork getP2PNetwork() {
427432
return networkRunner.getNetwork();
428433
}

besu/src/main/java/org/hyperledger/besu/services/SynchronizationServiceImpl.java

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,10 @@ public SynchronizationServiceImpl(
6161
this.protocolContext = protocolContext;
6262
this.protocolSchedule = protocolSchedule;
6363
this.syncState = syncState;
64-
this.worldStateArchive = Optional.ofNullable(worldStateArchive)
65-
.filter(z -> z instanceof BonsaiWorldStateProvider)
66-
.map(BonsaiWorldStateProvider.class::cast);
64+
this.worldStateArchive =
65+
Optional.ofNullable(worldStateArchive)
66+
.filter(z -> z instanceof BonsaiWorldStateProvider)
67+
.map(BonsaiWorldStateProvider.class::cast);
6768
}
6869

6970
@Override
@@ -102,9 +103,7 @@ public boolean setHeadUnsafe(final BlockHeader blockHeader, final BlockBody bloc
102103

103104
final MutableBlockchain blockchain = protocolContext.getBlockchain();
104105

105-
if (worldStateArchive
106-
.flatMap(archive -> archive.getMutable(coreHeader, true))
107-
.isPresent()) {
106+
if (worldStateArchive.flatMap(archive -> archive.getMutable(coreHeader, true)).isPresent()) {
108107
if (coreHeader.getParentHash().equals(blockchain.getChainHeadHash())) {
109108
LOG.atDebug()
110109
.setMessage(
@@ -131,20 +130,22 @@ public boolean isInitialSyncPhaseDone() {
131130
@Override
132131
public void disableWorldStateTrie() {
133132
// TODO MAYBE FIND A BEST WAY TO DELETE AND DISABLE TRIE
134-
worldStateArchive.ifPresent(archive -> {
135-
archive.getDefaultBonsaiWorldStateConfig().setTrieDisabled(true);
136-
final BonsaiWorldStateKeyValueStorage worldStateStorage = archive.getWorldStateStorage();
137-
final Optional<Hash> worldStateBlockHash = worldStateStorage.getWorldStateBlockHash();
138-
final Optional<Bytes> worldStateRootHash = worldStateStorage.getWorldStateRootHash();
139-
if (worldStateRootHash.isPresent() && worldStateBlockHash.isPresent()) {
140-
worldStateStorage.clearTrie();
141-
// keep root and block hash in the trie branch
142-
final BonsaiWorldStateKeyValueStorage.BonsaiUpdater updater = worldStateStorage.updater();
143-
updater.saveWorldState(worldStateBlockHash.get(), Bytes32.wrap(worldStateRootHash.get()),
144-
Bytes.EMPTY);
145-
updater.commit();
146-
worldStateStorage.upgradeToFullFlatDbMode();
147-
}
148-
});
133+
worldStateArchive.ifPresent(
134+
archive -> {
135+
archive.getDefaultBonsaiWorldStateConfig().setTrieDisabled(true);
136+
final BonsaiWorldStateKeyValueStorage worldStateStorage = archive.getWorldStateStorage();
137+
final Optional<Hash> worldStateBlockHash = worldStateStorage.getWorldStateBlockHash();
138+
final Optional<Bytes> worldStateRootHash = worldStateStorage.getWorldStateRootHash();
139+
if (worldStateRootHash.isPresent() && worldStateBlockHash.isPresent()) {
140+
worldStateStorage.clearTrie();
141+
// keep root and block hash in the trie branch
142+
final BonsaiWorldStateKeyValueStorage.BonsaiUpdater updater =
143+
worldStateStorage.updater();
144+
updater.saveWorldState(
145+
worldStateBlockHash.get(), Bytes32.wrap(worldStateRootHash.get()), Bytes.EMPTY);
146+
updater.commit();
147+
worldStateStorage.upgradeToFullFlatDbMode();
148+
}
149+
});
149150
}
150151
}

0 commit comments

Comments
 (0)