1
// Copyright (C) Moondance Labs Ltd.
2
// This file is part of Tanssi.
3

            
4
// Tanssi is free software: you can redistribute it and/or modify
5
// it under the terms of the GNU General Public License as published by
6
// the Free Software Foundation, either version 3 of the License, or
7
// (at your option) any later version.
8

            
9
// Tanssi is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
// GNU General Public License for more details.
13

            
14
// You should have received a copy of the GNU General Public License
15
// along with Tanssi.  If not, see <http://www.gnu.org/licenses/>.
16

            
17
use {
18
    sc_network::NetworkService,
19
    sc_network_sync::SyncingService,
20
    sp_core::H256,
21
    sp_runtime::traits::Block as BlockT,
22
    std::{collections::BTreeMap, sync::Arc},
23
};
24
// Frontier
25
use fc_db::Backend as FrontierBackend;
26
pub use {
27
    fc_rpc::EthBlockDataCacheTask,
28
    fc_rpc_core::types::{FeeHistoryCache, FeeHistoryCacheLimit, FilterPool},
29
    fc_storage::StorageOverride,
30
};
31

            
32
/// Extra dependencies for Ethereum compatibility.
33
pub struct EthDeps<C, P, CT, B: BlockT> {
34
    /// The client instance to use.
35
    pub client: Arc<C>,
36
    /// Transaction pool instance.
37
    pub pool: Arc<P>,
38
    /// Graph pool instance.
39
    pub graph: Arc<P>,
40
    /// Ethereum transaction converter.
41
    pub converter: Option<CT>,
42
    /// The Node authority flag
43
    pub is_authority: bool,
44
    /// Whether to enable dev signer
45
    pub enable_dev_signer: bool,
46
    /// Network service
47
    pub network: Arc<NetworkService<B, B::Hash>>,
48
    /// Chain syncing service
49
    pub sync: Arc<SyncingService<B>>,
50
    /// Frontier Backend.
51
    pub frontier_backend: Arc<FrontierBackend<B, C>>,
52
    /// Ethereum data access overrides.
53
    pub overrides: Arc<dyn StorageOverride<B>>,
54
    /// Cache for Ethereum block data.
55
    pub block_data_cache: Arc<EthBlockDataCacheTask<B>>,
56
    /// EthFilterApi pool.
57
    pub filter_pool: Option<FilterPool>,
58
    /// Maximum number of logs in a query.
59
    pub max_past_logs: u32,
60
    /// Maximum block range in a query.
61
    pub max_block_range: u32,
62
    /// Fee history cache.
63
    pub fee_history_cache: FeeHistoryCache,
64
    /// Maximum fee history cache size.
65
    pub fee_history_cache_limit: FeeHistoryCacheLimit,
66
    /// Maximum allowed gas limit will be ` block.gas_limit * execute_gas_limit_multiplier` when
67
    /// using eth_call/eth_estimateGas.
68
    pub execute_gas_limit_multiplier: u64,
69
    /// Mandated parent hashes for a given block hash.
70
    pub forced_parent_hashes: Option<BTreeMap<H256, H256>>,
71
}
72

            
73
impl<C, P, CT: Clone, B: BlockT> Clone for EthDeps<C, P, CT, B> {
74
    fn clone(&self) -> Self {
75
        Self {
76
            client: self.client.clone(),
77
            pool: self.pool.clone(),
78
            graph: self.graph.clone(),
79
            converter: self.converter.clone(),
80
            is_authority: self.is_authority,
81
            enable_dev_signer: self.enable_dev_signer,
82
            network: self.network.clone(),
83
            sync: self.sync.clone(),
84
            frontier_backend: self.frontier_backend.clone(),
85
            overrides: self.overrides.clone(),
86
            block_data_cache: self.block_data_cache.clone(),
87
            filter_pool: self.filter_pool.clone(),
88
            max_past_logs: self.max_past_logs,
89
            max_block_range: self.max_block_range,
90
            fee_history_cache: self.fee_history_cache.clone(),
91
            fee_history_cache_limit: self.fee_history_cache_limit,
92
            execute_gas_limit_multiplier: self.execute_gas_limit_multiplier,
93
            forced_parent_hashes: self.forced_parent_hashes.clone(),
94
        }
95
    }
96
}