Skip to content

Commit

Permalink
Fix engine_test
Browse files Browse the repository at this point in the history
  • Loading branch information
yperbasis committed Jul 23, 2022
1 parent 7ee9b7d commit 7aef9c0
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions core/silkworm/consensus/engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,28 @@ ValidationResult pre_validate_transaction(const Transaction& txn, uint64_t block
return ValidationResult::kOk;
}

std::unique_ptr<IEngine> engine_factory(const ChainConfig& chain_config) {
if (chain_config.terminal_total_difficulty.has_value()) {
return std::make_unique<MergeEngine>(chain_config);
}

static std::unique_ptr<IEngine> pre_merge_engine(const ChainConfig& chain_config) {
switch (chain_config.seal_engine) {
case SealEngineType::kEthash:
return std::make_unique<EthashEngine>(chain_config);
case SealEngineType::kNoProof:
return std::make_unique<NoProofEngine>(chain_config);
default:
return {};
return nullptr;
}
}

std::unique_ptr<IEngine> engine_factory(const ChainConfig& chain_config) {
std::unique_ptr<IEngine> engine{pre_merge_engine(chain_config)};
if (!engine) {
return nullptr;
}

if (chain_config.terminal_total_difficulty.has_value()) {
// TODO(yperbasis): refactor MergeEngine to wrap pre_merge_engine
return std::make_unique<MergeEngine>(chain_config);
} else {
return engine;
}
}

Expand Down

0 comments on commit 7aef9c0

Please sign in to comment.