multiversx_chain_vm/tx_execution/
blockchain_vm.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
use std::{ops::Deref, sync::Arc};

use multiversx_chain_vm_executor::Executor;

use super::BuiltinFunctionContainer;

pub struct BlockchainVM {
    pub builtin_functions: BuiltinFunctionContainer,
    pub executor: Box<dyn Executor + Send + Sync>,
}

#[derive(Clone)]
pub struct BlockchainVMRef(Arc<BlockchainVM>);

impl BlockchainVM {
    pub fn new(executor: Box<dyn Executor + Send + Sync>) -> Self {
        BlockchainVM {
            builtin_functions: BuiltinFunctionContainer,
            executor,
        }
    }
}

impl BlockchainVMRef {
    pub fn new(executor: Box<dyn Executor + Send + Sync>) -> Self {
        BlockchainVMRef(Arc::new(BlockchainVM::new(executor)))
    }
}

impl Deref for BlockchainVMRef {
    type Target = BlockchainVM;

    fn deref(&self) -> &Self::Target {
        self.0.deref()
    }
}