Skip to content
This repository was archived by the owner on Nov 6, 2020. It is now read-only.

Commit 3cbaf64

Browse files
committed
Beginnings of Ethash engine.
1 parent 648207d commit 3cbaf64

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

src/ethash.rs

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
use engine::Engine;
2+
use spec::Spec;
3+
use evm_schedule::EvmSchedule;
4+
use env_info::EnvInfo;
5+
6+
/// Engine using Ethash proof-of-work consensus algorithm, suitable for Ethereum
7+
/// mainnet chains in the Olympic, Frontier and Homestead eras.
8+
pub struct Ethash {
9+
spec: Spec,
10+
}
11+
12+
impl Ethash {
13+
pub fn new_boxed(spec: Spec) -> Box<Engine> {
14+
Box::new(NullEngine{spec: spec})
15+
}
16+
}
17+
18+
impl Engine for NullEngine {
19+
fn name(&self) -> &str { "Ethash" }
20+
fn spec(&self) -> &Spec { &self.spec }
21+
fn evm_schedule(&self, _env_info: &EnvInfo) -> EvmSchedule { EvmSchedule::new_frontier() }
22+
}

src/spec.rs

+1
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ impl Spec {
9393
pub fn to_engine(self) -> Result<Box<Engine>, EthcoreError> {
9494
match self.engine_name.as_ref() {
9595
"NullEngine" => Ok(NullEngine::new_boxed(self)),
96+
"Ethash" => Ok(Ethash::new_boxed(self)),
9697
_ => Err(EthcoreError::UnknownName)
9798
}
9899
}

0 commit comments

Comments
 (0)