mirror of
https://git.ghostchain.io/proxmio/ghost-node.git
synced 2025-12-27 11:19:57 +00:00
additional network field, that represents default rate limit measured in blocks
Signed-off-by: Uncle Stretch <uncle.stretch@ghostchain.io>
This commit is contained in:
@@ -56,6 +56,7 @@ pub struct NetworkData {
|
||||
pub topic_name: Vec<u8>,
|
||||
pub network_type: NetworkType,
|
||||
pub finality_delay: u64,
|
||||
pub rate_limit_delay: u64,
|
||||
pub block_distance: u64,
|
||||
pub incoming_fee: u32,
|
||||
pub outgoing_fee: u32,
|
||||
@@ -158,6 +159,7 @@ pub mod module {
|
||||
NetworkNameUpdated { chain_id: T::NetworkId, chain_name: Vec<u8> },
|
||||
NetworkEndpointUpdated { chain_id: T::NetworkId, default_endpoint: Vec<u8> },
|
||||
NetworkFinalityDelayUpdated { chain_id: T::NetworkId, finality_delay: u64 },
|
||||
NetworkRateLimitDelayUpdated { chain_id: T::NetworkId, rate_limit_delay: u64 },
|
||||
NetworkBlockDistanceUpdated { chain_id: T::NetworkId, block_distance: u64 },
|
||||
NetworkTypeUpdated { chain_id: T::NetworkId, network_type: NetworkType },
|
||||
NetworkGatekeeperUpdated { chain_id: T::NetworkId, gatekeeper: Vec<u8> },
|
||||
@@ -303,6 +305,20 @@ pub mod module {
|
||||
}
|
||||
|
||||
#[pallet::call_index(4)]
|
||||
#[pallet::weight(T::WeightInfo::update_network_rate_limit_delay())]
|
||||
pub fn update_network_rate_limit_delay(
|
||||
origin: OriginFor<T>,
|
||||
chain_id: T::NetworkId,
|
||||
rate_limit_delay: u64,
|
||||
) -> DispatchResult {
|
||||
T::UpdateOrigin::ensure_origin_or_root(origin)?;
|
||||
Self::do_update_network_rate_limit_delay(
|
||||
chain_id,
|
||||
rate_limit_delay,
|
||||
)
|
||||
}
|
||||
|
||||
#[pallet::call_index(5)]
|
||||
#[pallet::weight(T::WeightInfo::update_network_block_distance())]
|
||||
pub fn update_network_block_distance(
|
||||
origin: OriginFor<T>,
|
||||
@@ -316,7 +332,7 @@ pub mod module {
|
||||
)
|
||||
}
|
||||
|
||||
#[pallet::call_index(5)]
|
||||
#[pallet::call_index(6)]
|
||||
#[pallet::weight(T::WeightInfo::update_network_type())]
|
||||
pub fn update_network_type(
|
||||
origin: OriginFor<T>,
|
||||
@@ -330,7 +346,7 @@ pub mod module {
|
||||
)
|
||||
}
|
||||
|
||||
#[pallet::call_index(6)]
|
||||
#[pallet::call_index(7)]
|
||||
#[pallet::weight(T::WeightInfo::update_network_gatekeeper())]
|
||||
pub fn update_network_gatekeeper(
|
||||
origin: OriginFor<T>,
|
||||
@@ -344,7 +360,7 @@ pub mod module {
|
||||
)
|
||||
}
|
||||
|
||||
#[pallet::call_index(7)]
|
||||
#[pallet::call_index(8)]
|
||||
#[pallet::weight(T::WeightInfo::update_network_topic_name())]
|
||||
pub fn update_network_topic_name(
|
||||
origin: OriginFor<T>,
|
||||
@@ -358,7 +374,7 @@ pub mod module {
|
||||
)
|
||||
}
|
||||
|
||||
#[pallet::call_index(8)]
|
||||
#[pallet::call_index(9)]
|
||||
#[pallet::weight(T::WeightInfo::update_incoming_network_fee())]
|
||||
pub fn update_incoming_network_fee(
|
||||
origin: OriginFor<T>,
|
||||
@@ -372,7 +388,7 @@ pub mod module {
|
||||
)
|
||||
}
|
||||
|
||||
#[pallet::call_index(9)]
|
||||
#[pallet::call_index(10)]
|
||||
#[pallet::weight(T::WeightInfo::update_outgoing_network_fee())]
|
||||
pub fn update_outgoing_network_fee(
|
||||
origin: OriginFor<T>,
|
||||
@@ -386,7 +402,7 @@ pub mod module {
|
||||
)
|
||||
}
|
||||
|
||||
#[pallet::call_index(10)]
|
||||
#[pallet::call_index(11)]
|
||||
#[pallet::weight(T::WeightInfo::remove_network())]
|
||||
pub fn remove_network(
|
||||
origin: OriginFor<T>,
|
||||
@@ -465,7 +481,7 @@ impl<T: Config> Pallet<T> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Update existent network default endpoint.
|
||||
/// Update existent network default finality delay.
|
||||
pub fn do_update_network_finality_delay(
|
||||
chain_id: T::NetworkId,
|
||||
finality_delay: u64,
|
||||
@@ -484,6 +500,25 @@ impl<T: Config> Pallet<T> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Update existent network default rate limit delay.
|
||||
pub fn do_update_network_rate_limit_delay(
|
||||
chain_id: T::NetworkId,
|
||||
rate_limit_delay: u64,
|
||||
) -> DispatchResult {
|
||||
Networks::<T>::try_mutate(&chain_id, |maybe_network| -> DispatchResult {
|
||||
ensure!(maybe_network.is_some(), Error::<T>::NetworkDoesNotExist);
|
||||
let net = maybe_network.as_mut().unwrap();
|
||||
net.rate_limit_delay = rate_limit_delay;
|
||||
*maybe_network = Some(net.clone());
|
||||
Ok(())
|
||||
})?;
|
||||
Self::deposit_event(Event::<T>::NetworkRateLimitDelayUpdated {
|
||||
chain_id,
|
||||
rate_limit_delay,
|
||||
});
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Update existent network default max distance between blocks.
|
||||
pub fn do_update_network_block_distance(
|
||||
chain_id: T::NetworkId,
|
||||
|
||||
Reference in New Issue
Block a user