|
|
|
@ -46,9 +46,17 @@ public class GenesisConfigurationFactory { |
|
|
|
|
|
|
|
|
|
public static Optional<String> createCliqueGenesisConfig( |
|
|
|
|
final Collection<? extends RunnableNode> validators) { |
|
|
|
|
final String template = readGenesisFile("/clique/clique.json"); |
|
|
|
|
return createCliqueGenesisConfig(validators, CliqueOptions.DEFAULT); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static Optional<String> createCliqueGenesisConfig( |
|
|
|
|
final Collection<? extends RunnableNode> validators, final CliqueOptions cliqueOptions) { |
|
|
|
|
final String template = readGenesisFile("/clique/clique.json.tpl"); |
|
|
|
|
|
|
|
|
|
return updateGenesisExtraData( |
|
|
|
|
validators, template, CliqueExtraData::createGenesisExtraDataString); |
|
|
|
|
validators, |
|
|
|
|
updateGenesisCliqueOptions(template, cliqueOptions), |
|
|
|
|
CliqueExtraData::createGenesisExtraDataString); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static Optional<String> createIbft2GenesisConfig( |
|
|
|
@ -138,6 +146,14 @@ public class GenesisConfigurationFactory { |
|
|
|
|
return Optional.of(genesis); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static String updateGenesisCliqueOptions( |
|
|
|
|
final String template, final CliqueOptions cliqueOptions) { |
|
|
|
|
return template |
|
|
|
|
.replace("%blockperiodseconds%", String.valueOf(cliqueOptions.blockPeriodSeconds)) |
|
|
|
|
.replace("%epochlength%", String.valueOf(cliqueOptions.epochLength)) |
|
|
|
|
.replace("%createemptyblocks%", String.valueOf(cliqueOptions.createEmptyBlocks)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@SuppressWarnings("UnstableApiUsage") |
|
|
|
|
public static String readGenesisFile(final String filepath) { |
|
|
|
|
try { |
|
|
|
@ -147,4 +163,8 @@ public class GenesisConfigurationFactory { |
|
|
|
|
throw new IllegalStateException("Unable to get test genesis config " + filepath); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public record CliqueOptions(int blockPeriodSeconds, int epochLength, boolean createEmptyBlocks) { |
|
|
|
|
public static final CliqueOptions DEFAULT = new CliqueOptions(10, 30000, true); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|