55use std:: { cmp:: max, rc:: Rc } ;
66
77use crate :: ledger_info:: get_key_durability;
8- #[ cfg( any( test, feature = "unstable-next-api" ) ) ]
98use crate :: storage:: EntryWithLiveUntil ;
109#[ cfg( any( test, feature = "recording_mode" ) ) ]
1110use crate :: {
@@ -80,7 +79,6 @@ pub struct InvokeHostFunctionRecordingModeResult {
8079 pub contract_events : Vec < ContractEvent > ,
8180 /// Size of the encoded contract events and the return value.
8281 /// Non-zero only when invocation has succeeded.
83- #[ cfg( any( test, feature = "unstable-next-api" ) ) ]
8482 pub contract_events_and_return_value_size : u32 ,
8583}
8684
@@ -160,14 +158,7 @@ pub fn get_ledger_changes(
160158 new_live_until_ledger : 0 ,
161159 } ) ;
162160 }
163- #[ cfg( any( test, feature = "unstable-next-api" ) ) ]
164161 let entry_with_live_until = init_storage_snapshot. get ( key) ?;
165- #[ cfg( not( any( test, feature = "unstable-next-api" ) ) ) ]
166- let entry_with_live_until = if init_storage_snapshot. has ( key) ? {
167- Some ( init_storage_snapshot. get ( key) ?)
168- } else {
169- None
170- } ;
171162 if let Some ( ( old_entry, old_live_until_ledger) ) = entry_with_live_until {
172163 let mut buf = vec ! [ ] ;
173164 metered_write_xdr ( budget, old_entry. as_ref ( ) , & mut buf) ?;
@@ -567,14 +558,7 @@ pub fn invoke_host_function_in_recording_mode(
567558 let mut encoded_ttl_entries = Vec :: with_capacity ( storage. footprint . 0 . len ( ) ) ;
568559 let mut read_bytes = 0_u32 ;
569560 for ( lk, _) in & storage. footprint . 0 {
570- #[ cfg( any( test, feature = "unstable-next-api" ) ) ]
571561 let entry_with_live_until = ledger_snapshot. get ( lk) ?;
572- #[ cfg( not( any( test, feature = "unstable-next-api" ) ) ) ]
573- let entry_with_live_until = if ledger_snapshot. has ( lk) ? {
574- Some ( ledger_snapshot. get ( lk) ?)
575- } else {
576- None
577- } ;
578562 if let Some ( ( le, live_until) ) = entry_with_live_until {
579563 let encoded_le = host. to_xdr_non_metered ( & * le) ?;
580564 read_bytes = read_bytes. saturating_add ( encoded_le. len ( ) as u32 ) ;
@@ -652,7 +636,6 @@ pub fn invoke_host_function_in_recording_mode(
652636 auth : output_auth,
653637 ledger_changes,
654638 contract_events,
655- #[ cfg( any( test, feature = "unstable-next-api" ) ) ]
656639 contract_events_and_return_value_size,
657640 } )
658641}
@@ -831,7 +814,6 @@ struct StorageMapSnapshotSource<'a> {
831814 map : & ' a StorageMap ,
832815}
833816
834- #[ cfg( any( test, feature = "unstable-next-api" ) ) ]
835817impl < ' a > SnapshotSource for StorageMapSnapshotSource < ' a > {
836818 fn get ( & self , key : & Rc < LedgerKey > ) -> Result < Option < EntryWithLiveUntil > , HostError > {
837819 if let Some ( Some ( ( entry, live_until_ledger) ) ) =
@@ -843,30 +825,3 @@ impl<'a> SnapshotSource for StorageMapSnapshotSource<'a> {
843825 }
844826 }
845827}
846-
847- #[ cfg( not( any( test, feature = "unstable-next-api" ) ) ) ]
848- impl < ' a > SnapshotSource for StorageMapSnapshotSource < ' a > {
849- fn get ( & self , key : & Rc < LedgerKey > ) -> Result < ( Rc < LedgerEntry > , Option < u32 > ) , HostError > {
850- if let Some ( Some ( ( entry, live_until_ledger) ) ) =
851- self . map . get :: < Rc < LedgerKey > > ( key, self . budget ) ?
852- {
853- Ok ( ( Rc :: clone ( entry) , * live_until_ledger) )
854- } else {
855- Err ( HostError :: from ( (
856- ScErrorType :: Storage ,
857- ScErrorCode :: InternalError ,
858- ) ) )
859- }
860- }
861-
862- fn has ( & self , key : & Rc < LedgerKey > ) -> Result < bool , HostError > {
863- if let Some ( maybe_value) = self . map . get :: < Rc < LedgerKey > > ( key, self . budget ) ? {
864- Ok ( maybe_value. is_some ( ) )
865- } else {
866- Err ( HostError :: from ( (
867- ScErrorType :: Storage ,
868- ScErrorCode :: InternalError ,
869- ) ) )
870- }
871- }
872- }
0 commit comments