fuel_core_gas_price_service/
static_updater.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
37
use crate::common::gas_price_algorithm::GasPriceAlgorithm;
use fuel_core_types::fuel_types::BlockHeight;

pub struct StaticAlgorithmUpdater {
    static_price: u64,
}

impl StaticAlgorithmUpdater {
    pub fn new(static_price: u64) -> Self {
        Self { static_price }
    }
}

#[derive(Clone, Debug)]
pub struct StaticAlgorithm {
    price: u64,
}

impl StaticAlgorithm {
    pub fn new(price: u64) -> Self {
        Self { price }
    }

    pub fn price(&self) -> u64 {
        self.price
    }
}

impl GasPriceAlgorithm for StaticAlgorithm {
    fn next_gas_price(&self) -> u64 {
        self.price()
    }

    fn worst_case_gas_price(&self, _block_height: BlockHeight) -> u64 {
        self.price()
    }
}