File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -108,8 +108,20 @@ pub struct LightClient<P, S> {
108108 stake_tables : RwLock < BTreeMap < EpochNumber , Arc < StakeTable > > > ,
109109}
110110
111- impl < P , S > AsRef < S > for LightClient < P , S > {
112- fn as_ref ( & self ) -> & S {
111+ impl < P , S > LightClient < P , S > {
112+ pub fn into_storage ( self ) -> P {
113+ self . db
114+ }
115+
116+ pub fn storage ( & self ) -> & P {
117+ & self . db
118+ }
119+
120+ pub fn into_inner ( self ) -> S {
121+ self . server
122+ }
123+
124+ pub fn inner ( & self ) -> & S {
113125 & self . server
114126 }
115127}
Original file line number Diff line number Diff line change 11#[ cfg( feature = "client" ) ]
22use std:: {
3+ cmp:: min,
34 collections:: HashMap ,
45 path:: PathBuf ,
56 str:: FromStr ,
@@ -556,12 +557,17 @@ impl Storage for SqliteStorage {
556557 ) -> Result < Option < ( EpochNumber , StakeTableState , Version , Version ) > > {
557558 let mut tx = self . pool . begin ( ) . await ?;
558559
560+ // The largest epoch number the database can represent is `i64::MAX`. Since we are only
561+ // looking for a lower bound, if requested for an epoch number that can overflow, we can
562+ // simply return the lower bound of `i64::MAX`.
563+ let epoch = min ( * epoch, i64:: MAX as u64 ) as i64 ;
564+
559565 let Some ( ( epoch, epoch_root_protocol_version, next_epoch_root_protocol_version) ) =
560566 query_as :: < _ , ( i64 , String , String ) > (
561567 "SELECT epoch, epoch_root_protocol_version, next_epoch_root_protocol_version FROM \
562568 stake_table_epoch WHERE epoch <= $1 ORDER BY epoch DESC LIMIT 1",
563569 )
564- . bind ( * epoch as i64 )
570+ . bind ( epoch)
565571 . fetch_optional ( tx. as_mut ( ) )
566572 . await
567573 . context ( "loading epoch lower bound" ) ?
You can’t perform that action at this time.
0 commit comments