@@ -46,8 +46,8 @@ use frame_system::{
4646} ;
4747use codec:: {
4848 Encode ,
49- Decode ,
50- Codec ,
49+ Decode ,
50+ Codec ,
5151 EncodeLike
5252} ;
5353use sp_core:: {
@@ -105,8 +105,7 @@ pub trait Trait: system::Trait{
105105******************************************************************************/
106106decl_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 ) ]
151150struct 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}
0 commit comments