Skip to content

Commit e9bbf06

Browse files
committed
Update NoiseKey type and update make_new_contract fn
1 parent 6465556 commit e9bbf06

File tree

3 files changed

+16
-14
lines changed

3 files changed

+16
-14
lines changed

datdot-node/pallets/datdot/src/lib.rs

+14-12
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ use frame_system::{
4646
};
4747
use codec::{
4848
Encode,
49-
Decode,
50-
Codec,
49+
Decode,
50+
Codec,
5151
EncodeLike
5252
};
5353
use sp_core::{
@@ -105,8 +105,7 @@ pub trait Trait: system::Trait{
105105
******************************************************************************/
106106
decl_event!(
107107
pub enum Event<T> where
108-
<T as Trait>::FeedId,
109-
<T as Trait>::UserId,
108+
<T as Trait>::FeedId,
110109
<T as Trait>::ContractId,
111110
<T as Trait>::PlanId,
112111
<T as Trait>::ChallengeId,
@@ -117,7 +116,7 @@ decl_event!(
117116
NewPlan(PlanId),
118117
/// A new contract between publisher, encoder, and hoster (many contracts per plan)
119118
/// (Encoder, Hoster,...)
120-
NewContract(UserId, UserId, FeedId, ContractId, Ranges<ChunkIndex>),
119+
NewContract(ContractId),
121120
/// Hosting contract started
122121
HostingStarted(ContractId),
123122
/// New proof-of-storage challenge
@@ -145,7 +144,7 @@ enum Role {
145144
Attestor
146145
}
147146

148-
type NoiseKey = Vec<u8>;
147+
type NoiseKey = H512;
149148

150149
#[derive(Decode, PartialEq, Eq, Encode, Clone, Default, RuntimeDebug)]
151150
struct User<T: Trait> {
@@ -257,7 +256,7 @@ impl Node {
257256
}
258257
if max_index > offset {
259258
let mut next_result = true;
260-
while next_result {
259+
while next_result {
261260
match result {
262261
Some(index) => {
263262
if index + interval + furthest_leaf > max_index {
@@ -267,7 +266,7 @@ impl Node {
267266
}
268267
},
269268
None => {
270-
result = Some(offset);
269+
result = Some(offset);
271270
},
272271
}
273272
}
@@ -561,7 +560,7 @@ decl_module!{
561560
fn submit_attestation_report(origin, attestation_id: T::AttestationId, report: Report ){
562561
let user_address = ensure_signed(origin)?;
563562
if let Some(attestation) = <GetAttestationByID<T>>::get(attestation_id){
564-
563+
565564
}
566565
/*
567566
console.log('Submitting Proof Of Retrievability Attestation with ID:', attestationID)
@@ -607,6 +606,7 @@ impl<T: Trait> Module<T> {
607606
hoster_option: Option<T::UserId>,
608607
plan_option: Option<T::PlanId>
609608
){
609+
let mut contract_id : T::ContractId;
610610
let mut random_hoster_option = None;
611611
let mut random_encoder_option = None;
612612
let mut random_plan_option = None;
@@ -621,8 +621,10 @@ impl<T: Trait> Module<T> {
621621
encoder: encoder_id,
622622
hoster: hoster_id
623623
};
624-
<GetContractByID<T>>::insert(x, new_contract);
624+
contract_id = x.clone();
625+
<GetContractByID<T>>::insert(x, new_contract.clone());
625626
<GetNextContractID<T>>::put(x+One::one());
627+
Self::deposit_event(RawEvent::NewContract(contract_id.clone()));
626628
};
627629
},
628630
(None, None, Some(plan_id)) => { // Condition: if planID && encoders available & hosters available
@@ -715,7 +717,7 @@ impl<T: Trait> Module<T> {
715717
Self::get_random_of_vec(influence, members, count)
716718
}
717719

718-
720+
719721
fn get_random_of_role_filtered<F>(influence: &[u8], role: &Role, count: u32, filter: F) -> Vec<T::UserId>
720722
where F: Fn(RoleValue) -> bool {
721723
let members : Vec<T::UserId> = <Roles<T>>::iter_prefix(role).filter_map(|x|{
@@ -727,6 +729,6 @@ impl<T: Trait> Module<T> {
727729
}).collect();
728730
Self::get_random_of_vec(influence, members, count)
729731
}
730-
732+
731733

732734
}

datdot-node/pallets/datdot/types.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"ChallengeId": "u32",
99
"PlanId": "u32",
1010
"AttestationId": "u32",
11-
"NoiseKey": "Vec<u8>",
11+
"NoiseKey": "H512",
1212
"FeedKey": "Public",
1313
"Ranges": "Vec<(ChunkIndex, ChunkIndex)>",
1414
"Nonce": "u64",

types.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"ChallengeId": "u32",
1111
"PlanId": "u32",
1212
"AttestationId": "u32",
13-
"NoiseKey": "Vec<u8>",
13+
"NoiseKey": "H512",
1414
"FeedKey": "Public",
1515
"Ranges": "Vec<(ChunkIndex, ChunkIndex)>",
1616
"Nonce": "u64",

0 commit comments

Comments
 (0)