|
|
|
@ -20,6 +20,7 @@ import tech.pegasys.pantheon.ethereum.core.Wei; |
|
|
|
|
import tech.pegasys.pantheon.ethereum.mainnet.MainnetBlockProcessor.TransactionReceiptFactory; |
|
|
|
|
import tech.pegasys.pantheon.ethereum.vm.EVM; |
|
|
|
|
import tech.pegasys.pantheon.ethereum.vm.GasCalculator; |
|
|
|
|
import tech.pegasys.pantheon.metrics.MetricsSystem; |
|
|
|
|
|
|
|
|
|
import java.util.function.BiFunction; |
|
|
|
|
import java.util.function.Function; |
|
|
|
@ -31,7 +32,7 @@ public class ProtocolSpecBuilder<T> { |
|
|
|
|
private BlockHashFunction blockHashFunction; |
|
|
|
|
private TransactionReceiptFactory transactionReceiptFactory; |
|
|
|
|
private DifficultyCalculator<T> difficultyCalculator; |
|
|
|
|
private Function<GasCalculator, EVM> evmBuilder; |
|
|
|
|
private BiFunction<GasCalculator, MetricsSystem, EVM> evmBuilder; |
|
|
|
|
private Function<GasCalculator, TransactionValidator> transactionValidatorBuilder; |
|
|
|
|
private Function<DifficultyCalculator<T>, BlockHeaderValidator<T>> blockHeaderValidatorBuilder; |
|
|
|
|
private Function<DifficultyCalculator<T>, BlockHeaderValidator<T>> ommerHeaderValidatorBuilder; |
|
|
|
@ -46,6 +47,7 @@ public class ProtocolSpecBuilder<T> { |
|
|
|
|
private TransactionReceiptType transactionReceiptType; |
|
|
|
|
private String name; |
|
|
|
|
private MiningBeneficiaryCalculator miningBeneficiaryCalculator; |
|
|
|
|
private MetricsSystem metricsSystem; |
|
|
|
|
|
|
|
|
|
public ProtocolSpecBuilder<T> gasCalculator(final Supplier<GasCalculator> gasCalculatorBuilder) { |
|
|
|
|
this.gasCalculatorBuilder = gasCalculatorBuilder; |
|
|
|
@ -74,7 +76,8 @@ public class ProtocolSpecBuilder<T> { |
|
|
|
|
return this; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public ProtocolSpecBuilder<T> evmBuilder(final Function<GasCalculator, EVM> evmBuilder) { |
|
|
|
|
public ProtocolSpecBuilder<T> evmBuilder( |
|
|
|
|
final BiFunction<GasCalculator, MetricsSystem, EVM> evmBuilder) { |
|
|
|
|
this.evmBuilder = evmBuilder; |
|
|
|
|
return this; |
|
|
|
|
} |
|
|
|
@ -160,6 +163,11 @@ public class ProtocolSpecBuilder<T> { |
|
|
|
|
return this; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public ProtocolSpecBuilder<T> metricsSystem(final MetricsSystem metricsSystem) { |
|
|
|
|
this.metricsSystem = metricsSystem; |
|
|
|
|
return this; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public <R> ProtocolSpecBuilder<R> changeConsensusContextType( |
|
|
|
|
final Function<DifficultyCalculator<R>, BlockHeaderValidator<R>> blockHeaderValidatorBuilder, |
|
|
|
|
final Function<DifficultyCalculator<R>, BlockHeaderValidator<R>> ommerHeaderValidatorBuilder, |
|
|
|
@ -208,9 +216,10 @@ public class ProtocolSpecBuilder<T> { |
|
|
|
|
checkNotNull(name, "Missing name"); |
|
|
|
|
checkNotNull(miningBeneficiaryCalculator, "Missing Mining Beneficiary Calculator"); |
|
|
|
|
checkNotNull(protocolSchedule, "Missing protocol schedule"); |
|
|
|
|
checkNotNull(metricsSystem, "Missing metrics system"); |
|
|
|
|
|
|
|
|
|
final GasCalculator gasCalculator = gasCalculatorBuilder.get(); |
|
|
|
|
final EVM evm = evmBuilder.apply(gasCalculator); |
|
|
|
|
final EVM evm = evmBuilder.apply(gasCalculator, metricsSystem); |
|
|
|
|
final TransactionValidator transactionValidator = |
|
|
|
|
transactionValidatorBuilder.apply(gasCalculator); |
|
|
|
|
final AbstractMessageProcessor contractCreationProcessor = |
|
|
|
|