@@ -6,7 +6,7 @@ use crate::{
6
6
metrics:: OverlayMetrics ,
7
7
storage:: PortalStorage ,
8
8
types:: {
9
- content_key:: { HistoryContentKey , OverlayContentKey } ,
9
+ content_key:: OverlayContentKey ,
10
10
messages:: {
11
11
Accept , ByteList , Content , CustomPayload , FindContent , FindNodes , Message , Nodes ,
12
12
Offer , Ping , Pong , ProtocolId , Request , Response , SszEnr ,
@@ -643,7 +643,7 @@ impl<TContentKey: OverlayContentKey + Send, TMetric: Metric + Send>
643
643
}
644
644
}
645
645
646
- /// Attempts to build a `Accept` response for an `Offer` request.
646
+ /// Attempts to build an `Accept` response for an `Offer` request.
647
647
fn handle_offer ( & self , request : Offer ) -> Result < Accept , OverlayRequestError > {
648
648
self . metrics
649
649
. as_ref ( )
@@ -659,21 +659,25 @@ impl<TContentKey: OverlayContentKey + Send, TMetric: Metric + Send>
659
659
let accept_keys = request. content_keys . clone ( ) ;
660
660
661
661
for ( i, key) in request. content_keys . into_iter ( ) . enumerate ( ) {
662
- // TODO: This will not work when we receive state Offer message with state content keys
663
- // we need to refactor it in a way to get access to the protocol id in this method
664
- let key = HistoryContentKey :: try_from ( key)
665
- . map_err ( |err| OverlayRequestError :: AcceptError ( err. to_string ( ) ) ) ?;
662
+ let key = ( TContentKey :: try_from) ( key) . map_err ( |_| {
663
+ OverlayRequestError :: AcceptError ( format ! (
664
+ "Unable to build content key from OFFER request."
665
+ ) )
666
+ } ) ?;
667
+
666
668
requested_keys
667
669
. set (
668
670
i,
669
- self . storage . read ( ) . should_store ( & key) . map_err ( |_ | {
670
- OverlayRequestError :: AcceptError (
671
- "Portal storage error: unable to check content availability" . to_owned ( ) ,
672
- )
671
+ self . storage . read ( ) . should_store ( & key) . map_err ( |err | {
672
+ OverlayRequestError :: AcceptError ( format ! (
673
+ "Unable to check content availability: {err}"
674
+ ) )
673
675
} ) ?,
674
676
)
675
- . map_err ( |_| {
676
- OverlayRequestError :: AcceptError ( "Unable to set requested keys bits" . to_owned ( ) )
677
+ . map_err ( |err| {
678
+ OverlayRequestError :: AcceptError ( format ! (
679
+ "Unable to set requested keys bits: {err:?}"
680
+ ) )
677
681
} ) ?;
678
682
}
679
683
0 commit comments