@@ -46,8 +46,8 @@ use frame_system::{
46
46
} ;
47
47
use codec:: {
48
48
Encode ,
49
- Decode ,
50
- Codec ,
49
+ Decode ,
50
+ Codec ,
51
51
EncodeLike
52
52
} ;
53
53
use sp_core:: {
@@ -105,8 +105,7 @@ pub trait Trait: system::Trait{
105
105
******************************************************************************/
106
106
decl_event ! (
107
107
pub enum Event <T > where
108
- <T as Trait >:: FeedId ,
109
- <T as Trait >:: UserId ,
108
+ <T as Trait >:: FeedId ,
110
109
<T as Trait >:: ContractId ,
111
110
<T as Trait >:: PlanId ,
112
111
<T as Trait >:: ChallengeId ,
@@ -117,7 +116,7 @@ decl_event!(
117
116
NewPlan ( PlanId ) ,
118
117
/// A new contract between publisher, encoder, and hoster (many contracts per plan)
119
118
/// (Encoder, Hoster,...)
120
- NewContract ( UserId , UserId , FeedId , ContractId , Ranges < ChunkIndex > ) ,
119
+ NewContract ( ContractId ) ,
121
120
/// Hosting contract started
122
121
HostingStarted ( ContractId ) ,
123
122
/// New proof-of-storage challenge
@@ -145,7 +144,7 @@ enum Role {
145
144
Attestor
146
145
}
147
146
148
- type NoiseKey = Vec < u8 > ;
147
+ type NoiseKey = H512 ;
149
148
150
149
#[ derive( Decode , PartialEq , Eq , Encode , Clone , Default , RuntimeDebug ) ]
151
150
struct User < T : Trait > {
@@ -257,7 +256,7 @@ impl Node {
257
256
}
258
257
if max_index > offset {
259
258
let mut next_result = true ;
260
- while next_result {
259
+ while next_result {
261
260
match result {
262
261
Some ( index) => {
263
262
if index + interval + furthest_leaf > max_index {
@@ -267,7 +266,7 @@ impl Node {
267
266
}
268
267
} ,
269
268
None => {
270
- result = Some ( offset) ;
269
+ result = Some ( offset) ;
271
270
} ,
272
271
}
273
272
}
@@ -561,7 +560,7 @@ decl_module!{
561
560
fn submit_attestation_report( origin, attestation_id: T :: AttestationId , report: Report ) {
562
561
let user_address = ensure_signed( origin) ?;
563
562
if let Some ( attestation) = <GetAttestationByID <T >>:: get( attestation_id) {
564
-
563
+
565
564
}
566
565
/*
567
566
console.log('Submitting Proof Of Retrievability Attestation with ID:', attestationID)
@@ -607,6 +606,7 @@ impl<T: Trait> Module<T> {
607
606
hoster_option : Option < T :: UserId > ,
608
607
plan_option : Option < T :: PlanId >
609
608
) {
609
+ let mut contract_id : T :: ContractId ;
610
610
let mut random_hoster_option = None ;
611
611
let mut random_encoder_option = None ;
612
612
let mut random_plan_option = None ;
@@ -621,8 +621,10 @@ impl<T: Trait> Module<T> {
621
621
encoder : encoder_id,
622
622
hoster : hoster_id
623
623
} ;
624
- <GetContractByID < T > >:: insert ( x, new_contract) ;
624
+ contract_id = x. clone ( ) ;
625
+ <GetContractByID < T > >:: insert ( x, new_contract. clone ( ) ) ;
625
626
<GetNextContractID < T > >:: put ( x+One :: one ( ) ) ;
627
+ Self :: deposit_event ( RawEvent :: NewContract ( contract_id. clone ( ) ) ) ;
626
628
} ;
627
629
} ,
628
630
( None , None , Some ( plan_id) ) => { // Condition: if planID && encoders available & hosters available
@@ -715,7 +717,7 @@ impl<T: Trait> Module<T> {
715
717
Self :: get_random_of_vec ( influence, members, count)
716
718
}
717
719
718
-
720
+
719
721
fn get_random_of_role_filtered < F > ( influence : & [ u8 ] , role : & Role , count : u32 , filter : F ) -> Vec < T :: UserId >
720
722
where F : Fn ( RoleValue ) -> bool {
721
723
let members : Vec < T :: UserId > = <Roles < T > >:: iter_prefix ( role) . filter_map ( |x|{
@@ -727,6 +729,6 @@ impl<T: Trait> Module<T> {
727
729
} ) . collect ( ) ;
728
730
Self :: get_random_of_vec ( influence, members, count)
729
731
}
730
-
732
+
731
733
732
734
}
0 commit comments