Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename MergeOptions to MergeConfigOptions to follow the standard #3451

Merged
merged 1 commit into from
Feb 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/
package org.hyperledger.besu.cli.options.unstable;

import static org.hyperledger.besu.config.experimental.MergeOptions.setMergeEnabled;
import static org.hyperledger.besu.config.experimental.MergeConfigOptions.setMergeEnabled;

import java.util.Stack;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy;

import org.hyperledger.besu.config.experimental.MergeConfigOptions;

import java.util.Stack;
import java.util.concurrent.atomic.AtomicBoolean;

Expand All @@ -26,7 +28,7 @@

@SuppressWarnings({"JdkObsolete"})
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class MergeOptionsTest {
public class MergeConfigOptionsTest {

@Test
public void shouldBeDisabledByDefault() {
Expand All @@ -41,20 +43,19 @@ public void shouldBeEnabledFromCliConsumer() {
mockStack.push("true");
new MergeOptions.MergeConfigConsumer().consumeParameters(mockStack, null, null);

assertThat(org.hyperledger.besu.config.experimental.MergeOptions.isMergeEnabled()).isTrue();
assertThat(MergeConfigOptions.isMergeEnabled()).isTrue();
}

@Test
public void shouldDoWithMergeEnabled() {
final AtomicBoolean check = new AtomicBoolean(false);
org.hyperledger.besu.config.experimental.MergeOptions.doIfMergeEnabled((() -> check.set(true)));
MergeConfigOptions.doIfMergeEnabled((() -> check.set(true)));
assertThat(check.get()).isTrue();
}

@Test
public void shouldThrowOnReconfigure() {
assertThatThrownBy(
() -> org.hyperledger.besu.config.experimental.MergeOptions.setMergeEnabled(false))
assertThatThrownBy(() -> MergeConfigOptions.setMergeEnabled(false))
.isInstanceOf(RuntimeException.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import java.util.Optional;

/** For now there is a static config that is driven by a command line option. */
public class MergeOptions {
public class MergeConfigOptions {
private static Optional<Boolean> mergeEnabled = Optional.empty();

public static void setMergeEnabled(final boolean bool) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/
package org.hyperledger.besu.ethereum.blockcreation;

import org.hyperledger.besu.config.experimental.MergeOptions;
import org.hyperledger.besu.config.experimental.MergeConfigOptions;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.datatypes.Wei;
Expand Down Expand Up @@ -189,7 +189,7 @@ protected Block createBlock(
.populateFrom(processableBlockHeader)
.ommersHash(
BodyValidation.ommersHash(
MergeOptions.isMergeEnabled() ? Collections.emptyList() : ommers))
MergeConfigOptions.isMergeEnabled() ? Collections.emptyList() : ommers))
.stateRoot(disposableWorldState.rootHash())
.transactionsRoot(
BodyValidation.transactionsRoot(transactionResults.getTransactions()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/
package org.hyperledger.besu.ethereum.blockcreation;

import org.hyperledger.besu.config.experimental.MergeOptions;
import org.hyperledger.besu.config.experimental.MergeConfigOptions;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.chain.MinedBlockObserver;
Expand Down Expand Up @@ -85,7 +85,7 @@ public PoWBlockMiner createMiner(
final Function<BlockHeader, PoWBlockCreator> blockCreator =
(header) ->
new PoWBlockCreator(
coinbase.orElseGet(() -> MergeOptions.isMergeEnabled() ? Address.ZERO : null),
coinbase.orElseGet(() -> MergeConfigOptions.isMergeEnabled() ? Address.ZERO : null),
() -> targetGasLimit.map(AtomicLong::longValue),
parent -> extraData,
pendingTransactions,
Expand Down