-
Notifications
You must be signed in to change notification settings - Fork 839
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into ed/etc_atlantis_fork
- Loading branch information
Showing
13 changed files
with
242 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
besu/src/main/java/org/hyperledger/besu/cli/options/PrunerOptions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* Copyright ConsenSys AG. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations under the License. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
package org.hyperledger.besu.cli.options; | ||
|
||
import org.hyperledger.besu.ethereum.worldstate.PrunerConfiguration; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
import picocli.CommandLine; | ||
|
||
public class PrunerOptions implements CLIOptions<PrunerConfiguration> { | ||
private static final String BLOCKS_RETAINED_FLAG = "--Xpruning-blocks-retained"; | ||
private static final String BLOCK_CONFIRMATIONS_FLAG = "--Xpruning-block-confirmations"; | ||
|
||
@CommandLine.Option( | ||
names = {BLOCKS_RETAINED_FLAG}, | ||
hidden = true, | ||
defaultValue = "1024", | ||
paramLabel = "<INTEGER>", | ||
description = | ||
"Minimum number of recent blocks for which to keep entire world state (default: ${DEFAULT-VALUE})", | ||
arity = "1") | ||
private long pruningBlocksRetained = PrunerConfiguration.DEFAULT_PRUNING_BLOCKS_RETAINED; | ||
|
||
@CommandLine.Option( | ||
names = {BLOCK_CONFIRMATIONS_FLAG}, | ||
defaultValue = "10", | ||
hidden = true, | ||
paramLabel = "<INTEGER>", | ||
description = | ||
"Minimum number of confirmations on a block before marking begins (default: ${DEFAULT-VALUE})", | ||
arity = "1") | ||
private long pruningBlockConfirmations = PrunerConfiguration.DEFAULT_PRUNING_BLOCK_CONFIRMATIONS; | ||
|
||
public static PrunerOptions create() { | ||
return new PrunerOptions(); | ||
} | ||
|
||
@Override | ||
public PrunerConfiguration toDomainObject() { | ||
return new PrunerConfiguration(pruningBlockConfirmations, pruningBlocksRetained); | ||
} | ||
|
||
public static PrunerOptions fromDomainObject(final PrunerConfiguration prunerConfiguration) { | ||
final PrunerOptions prunerOptions = new PrunerOptions(); | ||
prunerOptions.pruningBlockConfirmations = prunerConfiguration.getBlockConfirmations(); | ||
prunerOptions.pruningBlocksRetained = prunerConfiguration.getBlocksRetained(); | ||
return prunerOptions; | ||
} | ||
|
||
@Override | ||
public List<String> getCLIOptions() { | ||
return Arrays.asList( | ||
BLOCKS_RETAINED_FLAG, | ||
String.valueOf(pruningBlocksRetained), | ||
BLOCK_CONFIRMATIONS_FLAG, | ||
String.valueOf(pruningBlockConfirmations)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.