Beginnings of Ethash engine.
This commit is contained in:
parent
648207d8e8
commit
3cbaf64c51
22
src/ethash.rs
Normal file
22
src/ethash.rs
Normal file
@ -0,0 +1,22 @@
|
||||
use engine::Engine;
|
||||
use spec::Spec;
|
||||
use evm_schedule::EvmSchedule;
|
||||
use env_info::EnvInfo;
|
||||
|
||||
/// Engine using Ethash proof-of-work consensus algorithm, suitable for Ethereum
|
||||
/// mainnet chains in the Olympic, Frontier and Homestead eras.
|
||||
pub struct Ethash {
|
||||
spec: Spec,
|
||||
}
|
||||
|
||||
impl Ethash {
|
||||
pub fn new_boxed(spec: Spec) -> Box<Engine> {
|
||||
Box::new(NullEngine{spec: spec})
|
||||
}
|
||||
}
|
||||
|
||||
impl Engine for NullEngine {
|
||||
fn name(&self) -> &str { "Ethash" }
|
||||
fn spec(&self) -> &Spec { &self.spec }
|
||||
fn evm_schedule(&self, _env_info: &EnvInfo) -> EvmSchedule { EvmSchedule::new_frontier() }
|
||||
}
|
@ -93,6 +93,7 @@ impl Spec {
|
||||
pub fn to_engine(self) -> Result<Box<Engine>, EthcoreError> {
|
||||
match self.engine_name.as_ref() {
|
||||
"NullEngine" => Ok(NullEngine::new_boxed(self)),
|
||||
"Ethash" => Ok(Ethash::new_boxed(self)),
|
||||
_ => Err(EthcoreError::UnknownName)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user