Skip to content

Commit

Permalink
wip: 'cluster_id' is added to fingerprint payload
Browse files Browse the repository at this point in the history
  • Loading branch information
yahortsaryk committed Nov 26, 2024
1 parent ca60dde commit d781db9
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions pallets/ddc-payouts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ pub mod pallet {
IncorrectClusterId,
ClusterProtocolParamsNotSet,
TotalStoredBytesLessThanZero,
FingerprintIsAlreadyCommited,
FingerprintIsAlreadyCommitted,
}

#[pallet::storage]
Expand Down Expand Up @@ -314,6 +314,7 @@ pub mod pallet {

#[derive(Clone, Encode, Decode, RuntimeDebug, TypeInfo, PartialEq)]
pub struct BillingReportFingerprint<AccountId> {
pub cluster_id: ClusterId,
pub era_id: DdcEra,
pub start_era: i64,
pub end_era: i64,
Expand All @@ -324,7 +325,8 @@ pub mod pallet {

impl<AccountId> BillingReportFingerprint<AccountId> {
fn selective_hash<T: Config>(&self) -> Fingerprint {
let mut data = self.era_id.encode();
let mut data = self.cluster_id.encode();
data.extend_from_slice(&self.era_id.encode());
data.extend_from_slice(&self.start_era.encode());
data.extend_from_slice(&self.end_era.encode());
data.extend_from_slice(&self.payers_merkle_root.encode());
Expand Down Expand Up @@ -605,6 +607,7 @@ pub mod pallet {
ensure!(payees_merkle_root != Default::default(), Error::<T>::BadRequest);

let inited_fingerprint = BillingReportFingerprint::<T::AccountId> {
cluster_id,
era_id,
start_era,
end_era,
Expand All @@ -622,7 +625,7 @@ pub mod pallet {

ensure!(
fingerprint.validators.insert(validator),
Error::<T>::FingerprintIsAlreadyCommited
Error::<T>::FingerprintIsAlreadyCommitted
);

Fingerprints::<T>::insert(hash, fingerprint);
Expand Down

0 comments on commit d781db9

Please sign in to comment.