Skip to content

Commit

Permalink
payout <> clusters
Browse files Browse the repository at this point in the history
  • Loading branch information
Victor Genin committed Nov 13, 2023
1 parent 7ca5bf0 commit 6939d9e
Show file tree
Hide file tree
Showing 8 changed files with 206 additions and 100 deletions.
16 changes: 16 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 2 additions & 5 deletions pallets/ddc-clusters/src/cluster.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::pallet::Error;
use codec::{Decode, Encode};
use ddc_primitives::ClusterId;
use ddc_primitives::{ClusterId, ClusterPricingParams};
use frame_support::{pallet_prelude::*, parameter_types};
use scale_info::TypeInfo;
use sp_runtime::Perbill;
Expand Down Expand Up @@ -41,10 +41,7 @@ pub struct ClusterGovParams<Balance, BlockNumber> {
pub storage_bond_size: Balance,
pub storage_chill_delay: BlockNumber,
pub storage_unbonding_delay: BlockNumber,
pub unit_per_mb_stored: u128,
pub unit_per_mb_streamed: u128,
pub unit_per_put_request: u128,
pub unit_per_get_request: u128,
pub pricing: ClusterPricingParams,
}

impl<AccountId> Cluster<AccountId> {
Expand Down
10 changes: 9 additions & 1 deletion pallets/ddc-clusters/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use crate::{
cluster::{Cluster, ClusterError, ClusterGovParams, ClusterParams},
node_provider_auth::{NodeProviderAuthContract, NodeProviderAuthContractError},
};
use ddc_primitives::{ClusterId, NodePubKey, NodeType};
use ddc_primitives::{ClusterId, ClusterPricingParams, NodePubKey, NodeType};
use ddc_traits::{
cluster::{ClusterVisitor, ClusterVisitorError},
staking::{StakingVisitor, StakingVisitorError},
Expand Down Expand Up @@ -272,6 +272,14 @@ pub mod pallet {
}
}

fn get_pricing_params(
cluster_id: &ClusterId,
) -> Result<ClusterPricingParams, ClusterVisitorError> {
let cluster_gov_params = ClustersGovParams::<T>::try_get(cluster_id)
.map_err(|_| ClusterVisitorError::ClusterGovParamsNotSet)?;
Ok(cluster_gov_params.pricing)
}

fn get_chill_delay(
cluster_id: &ClusterId,
node_type: NodeType,
Expand Down
15 changes: 2 additions & 13 deletions pallets/ddc-payouts/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ sp-runtime = { version = "6.0.0", default-features = false, git = "https://githu
sp-staking = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.30" }
sp-std = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.30" }
sp-core = { version = "6.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.30", default-features = false }
byte-unit = { version = "4.0.19", default-features = false, features = ["u128"] }

[dev-dependencies]
sp-core = { version = "6.0.0", git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.30" }
Expand All @@ -25,17 +26,5 @@ substrate-test-utils = { version = "4.0.0-dev", git = "https://github.com/parity

[features]
default = ["std"]
std = [
"codec/std",
"ddc-primitives/std",
"frame-support/std",
"frame-system/std",
"frame-benchmarking/std",
"scale-info/std",
"sp-io/std",
"sp-runtime/std",
"sp-staking/std",
"sp-std/std",
"sp-core/std",
]
std = ["codec/std", "ddc-primitives/std", "frame-support/std", "frame-system/std", "frame-benchmarking/std", "scale-info/std", "sp-io/std", "sp-runtime/std", "sp-staking/std", "sp-std/std", "sp-core/std"]
runtime-benchmarks = ["frame-benchmarking/runtime-benchmarks"]
Loading

0 comments on commit 6939d9e

Please sign in to comment.