File tree Expand file tree Collapse file tree 7 files changed +13
-11
lines changed
Expand file tree Collapse file tree 7 files changed +13
-11
lines changed Original file line number Diff line number Diff line change @@ -325,7 +325,7 @@ pub mod pallet {
325325 pub ( super ) type VerifyReassignCount < T : Config > = StorageValue < _ , u8 , ValueQuery > ;
326326
327327 #[ pallet:: storage]
328- #[ pallet:: getter( fn chllenge_snap_shot ) ]
328+ #[ pallet:: getter( fn challenge_snap_shot ) ]
329329 pub ( super ) type ChallengeSnapShot < T : Config > =
330330 StorageMap < _ , Blake2_128Concat , AccountOf < T > , ChallengeInfo < T > > ;
331331
Original file line number Diff line number Diff line change @@ -23,6 +23,8 @@ impl<T: Config> Pallet<T> {
2323 ) -> DispatchResult {
2424 let mut segment_info_list: BoundedVec < SegmentInfo < T > , T :: SegmentCount > = Default :: default ( ) ;
2525 ensure ! ( complete_list. len( ) == FRAGMENT_COUNT as usize , Error :: <T >:: Unexpected ) ;
26+ let mut complete_list = complete_list;
27+ complete_list. sort_by_key ( |info| info. index ) ;
2628 for segment in deal_info. iter ( ) {
2729 let mut segment_info = SegmentInfo :: < T > {
2830 hash : segment. hash ,
Original file line number Diff line number Diff line change @@ -585,6 +585,8 @@ pub mod pallet {
585585 ensure ! ( <DealMap <T >>:: contains_key( & deal_hash) , Error :: <T >:: NonExistent ) ;
586586 ensure ! ( index as u32 <= FRAGMENT_COUNT , Error :: <T >:: SpecError ) ;
587587 ensure ! ( index > 0 , Error :: <T >:: SpecError ) ;
588+ let is_positive = T :: MinerControl :: is_positive ( & sender) ?;
589+ ensure ! ( is_positive, Error :: <T >:: MinerStateError ) ;
588590 <DealMap < T > >:: try_mutate ( & deal_hash, |deal_info_opt| -> DispatchResult {
589591 // can use unwrap because there was a judgment above
590592 let deal_info = deal_info_opt. as_mut ( ) . unwrap ( ) ;
@@ -615,10 +617,10 @@ pub mod pallet {
615617
616618 let deal_info = <DealMap < T > >:: try_get ( & deal_hash) . map_err ( |_| Error :: < T > :: NonExistent ) ?;
617619 let count = deal_info. segment_list . len ( ) as u128 ;
618- for ( index , complete_info) in deal_info. complete_list . iter ( ) . enumerate ( ) {
620+ for complete_info in deal_info. complete_list . iter ( ) {
619621 let mut hash_list: Vec < Box < [ u8 ; 256 ] > > = Default :: default ( ) ;
620622 for segment in & deal_info. segment_list {
621- let fragment_hash = segment. fragment_list [ index as usize ] ;
623+ let fragment_hash = segment. fragment_list [ ( complete_info . index - 1 ) as usize ] ;
622624 let hash_temp = fragment_hash. binary ( ) . map_err ( |_| Error :: < T > :: BugInvalid ) ?;
623625 hash_list. push ( hash_temp) ;
624626 }
Original file line number Diff line number Diff line change @@ -254,7 +254,7 @@ impl<T: Config> Pallet<T> {
254254
255255 <MinerItems < T > >:: try_mutate ( acc, |miner_opt| -> DispatchResult {
256256 let miner = miner_opt. as_mut ( ) . ok_or ( Error :: < T > :: Unexpected ) ?;
257- T :: StorageHandle :: sub_total_idle_space ( miner. idle_space ) ?;
257+ T :: StorageHandle :: sub_total_idle_space ( miner. idle_space + miner . lock_space ) ?;
258258 Self :: create_restoral_target ( acc, miner. service_space ) ?;
259259 miner. state = Self :: str_to_bound ( STATE_OFFLINE ) ?;
260260 let space_proof_info = miner. space_proof_info . clone ( ) . ok_or ( Error :: < T > :: NotpositiveState ) ?;
Original file line number Diff line number Diff line change @@ -593,6 +593,7 @@ pub mod pallet {
593593 <MinerItems < T > >:: try_mutate ( & sender, |miner_opt| -> DispatchResult {
594594 let miner = miner_opt. as_mut ( ) . ok_or ( Error :: < T > :: NotExisted ) ?;
595595 ensure ! ( miner. state == STATE_POSITIVE . as_bytes( ) . to_vec( ) , Error :: <T >:: StateError ) ;
596+ ensure ! ( miner. lock_space == 0 , Error :: <T >:: StateError ) ;
596597 if miner. lock_space != 0 {
597598 Err ( Error :: < T > :: StateError ) ?;
598599 }
@@ -646,7 +647,7 @@ pub mod pallet {
646647 ensure ! ( miner_info. state. to_vec( ) == STATE_LOCK . as_bytes( ) . to_vec( ) , Error :: <T >:: StateError ) ;
647648 // sub network total idle space.
648649
649- T :: StorageHandle :: sub_total_idle_space ( miner_info. idle_space ) ?;
650+ T :: StorageHandle :: sub_total_idle_space ( miner_info. idle_space + miner_info . lock_space ) ?;
650651
651652 Self :: execute_exit ( & miner) ?;
652653
Original file line number Diff line number Diff line change @@ -350,7 +350,7 @@ pub mod pallet {
350350 #[ pallet:: weight( Weight :: zero( ) ) ]
351351 pub fn update_price ( origin : OriginFor < T > ) -> DispatchResult {
352352 let _ = ensure_root ( origin) ?;
353- let default_price: BalanceOf < T > = 30u32 . saturated_into ( ) ;
353+ let default_price: BalanceOf < T > = 30_000_000_000_000u128 . try_into ( ) . map_err ( |_| Error :: < T > :: Overflow ) ? ;
354354 UnitPrice :: < T > :: put ( default_price) ;
355355
356356 Ok ( ( ) )
@@ -383,7 +383,7 @@ pub mod pallet {
383383 // minute
384384 expired : u32 ,
385385 ) -> DispatchResult {
386- let sender = ensure_signed ( origin) ?;
386+ let _ = ensure_signed ( origin) ?;
387387
388388 let expired: BlockNumberOf < T > = ( expired
389389 . checked_mul ( 6 ) . ok_or ( Error :: < T > :: Overflow ) ?) . saturated_into ( ) ;
Original file line number Diff line number Diff line change @@ -168,7 +168,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
168168 // `spec_version`, and `authoring_version` are the same between Wasm and native.
169169 // This value is set to 100 to notify Polkadot-JS App (https://polkadot.js.org/apps) to use
170170 // the compatible custom types.
171- spec_version : 100 ,
171+ spec_version : 107 ,
172172 impl_version : 1 ,
173173 apis : RUNTIME_API_VERSIONS ,
174174 transaction_version : 1 ,
@@ -864,9 +864,6 @@ impl pallet_timestamp::Config for Runtime {
864864 type WeightInfo = pallet_timestamp:: weights:: SubstrateWeight < Runtime > ;
865865}
866866
867- /// Existential deposit.
868- pub const EXISTENTIAL_DEPOSIT : u128 = 10_000_000 * 1000 * 100 ;
869-
870867parameter_types ! {
871868 pub const ExistentialDeposit : Balance = 1 * DOLLARS ;
872869 // For weight estimation, we assume that the most locks on an individual account will be 50.
You can’t perform that action at this time.
0 commit comments