cfx_executor/machine/
vm_factory.rs

1// Copyright 2019 Conflux Foundation. All rights reserved.
2// Conflux is free software and distributed under GNU General Public License.
3// See http://www.gnu.org/licenses/
4
5use cfx_vm_interpreter::{Factory as EvmFactory, VMType};
6use cfx_vm_types::{ActionParams, Exec, Spec};
7
8/// Virtual machine factory
9#[derive(Default, Clone)]
10pub struct VmFactory {
11    evm_factory: EvmFactory,
12}
13
14impl VmFactory {
15    pub fn create(
16        &self, params: ActionParams, spec: &Spec, depth: usize,
17    ) -> Box<dyn Exec> {
18        self.evm_factory.create(params, spec, depth)
19    }
20
21    pub fn new(cache_size: usize) -> Self {
22        VmFactory {
23            evm_factory: EvmFactory::new(VMType::Interpreter, cache_size),
24        }
25    }
26}
27
28impl From<EvmFactory> for VmFactory {
29    fn from(evm_factory: EvmFactory) -> Self { VmFactory { evm_factory } }
30}