diff --git a/trin-core/src/jsonrpc/types.rs b/trin-core/src/jsonrpc/types.rs index 67234e66b..8975b3c79 100644 --- a/trin-core/src/jsonrpc/types.rs +++ b/trin-core/src/jsonrpc/types.rs @@ -10,7 +10,7 @@ use validator::{Validate, ValidationError}; use crate::{ jsonrpc::endpoints::{HistoryEndpoint, StateEndpoint, TrinEndpoint}, portalnet::types::{ - content_key::OverlayContentKey, + content_key::{OverlayContentKey, RawContentKey}, messages::{ByteList, CustomPayload, SszEnr}, }, }; @@ -274,7 +274,7 @@ impl TryFrom<[&Value; 2]> for OfferParams { .collect(); if let Ok(content_keys) = content_keys { - let content_keys: Result>, _> = + let content_keys: Result, _> = content_keys.iter().map(hex::decode).collect(); if let Ok(content_keys) = content_keys { diff --git a/trin-core/src/portalnet/overlay.rs b/trin-core/src/portalnet/overlay.rs index 082a7c040..0ed77cee8 100644 --- a/trin-core/src/portalnet/overlay.rs +++ b/trin-core/src/portalnet/overlay.rs @@ -15,9 +15,12 @@ use crate::portalnet::{ }, }; -use crate::utp::{ - stream::{UtpListenerRequest, UtpSocket, BUF_SIZE}, - trin_helpers::{UtpAccept, UtpMessage}, +use crate::{ + portalnet::types::content_key::RawContentKey, + utp::{ + stream::{UtpListenerRequest, UtpSocket, BUF_SIZE}, + trin_helpers::{UtpAccept, UtpMessage}, + }, }; use discv5::{ enr::NodeId, @@ -331,7 +334,7 @@ impl /// Offer is also sent to nodes after FindContent (POKE) pub async fn send_offer( &self, - content_keys: Vec>, + content_keys: Vec, enr: Enr, ) -> Result { // Construct the request. diff --git a/trin-core/src/portalnet/overlay_service.rs b/trin-core/src/portalnet/overlay_service.rs index 2528ca851..a2efc48d3 100644 --- a/trin-core/src/portalnet/overlay_service.rs +++ b/trin-core/src/portalnet/overlay_service.rs @@ -19,7 +19,10 @@ use crate::{ utp::stream::UtpListenerRequest, }; -use crate::utp::{stream::UtpPayload, trin_helpers::UtpStreamId}; +use crate::{ + portalnet::types::content_key::RawContentKey, + utp::{stream::UtpPayload, trin_helpers::UtpStreamId}, +}; use delay_map::HashSetDelay; use discv5::{ enr::NodeId, @@ -776,7 +779,7 @@ impl } /// Process accepted uTP payload of the OFFER?ACCEPT stream - fn process_accept_utp_payload(&self, content_keys: Vec>, payload: UtpPayload) { + fn process_accept_utp_payload(&self, content_keys: Vec, payload: UtpPayload) { // TODO: Verify the payload, store the content and propagate gossip. debug!("DEBUG: Processing content keys: {content_keys:?}, with payload: {payload:?}"); } diff --git a/trin-core/src/portalnet/types/content_key.rs b/trin-core/src/portalnet/types/content_key.rs index be40f3648..e6fc3dfe7 100644 --- a/trin-core/src/portalnet/types/content_key.rs +++ b/trin-core/src/portalnet/types/content_key.rs @@ -6,6 +6,9 @@ use ssz::{self, Decode, Encode}; use ssz_derive::{Decode, Encode}; use ssz_types::{typenum, FixedVector, VariableList}; +/// Raw overlay content key +pub type RawContentKey = Vec; + /// Types whose values represent keys to lookup content items in an overlay network. /// Keys are serializable. pub trait OverlayContentKey: Into> + TryFrom> + Clone { diff --git a/trin-core/src/portalnet/types/messages.rs b/trin-core/src/portalnet/types/messages.rs index b66274d62..5a2de62e9 100644 --- a/trin-core/src/portalnet/types/messages.rs +++ b/trin-core/src/portalnet/types/messages.rs @@ -17,7 +17,7 @@ use ssz_types::{typenum, BitList, VariableList}; use thiserror::Error; use validator::ValidationError; -use crate::portalnet::Enr; +use crate::portalnet::{types::content_key::RawContentKey, Enr}; pub type ByteList = VariableList; @@ -492,7 +492,7 @@ impl TryInto for Content { #[derive(Debug, PartialEq, Clone, Encode, Decode)] pub struct Offer { - pub content_keys: Vec>, + pub content_keys: Vec, } #[derive(Debug, PartialEq, Clone, Encode, Decode)] diff --git a/trin-core/src/utp/stream.rs b/trin-core/src/utp/stream.rs index c02687947..91d170bfc 100644 --- a/trin-core/src/utp/stream.rs +++ b/trin-core/src/utp/stream.rs @@ -21,7 +21,10 @@ use tokio::{ use crate::{ locks::RwLoggingExt, - portalnet::types::messages::{ByteList, Content::Content, ProtocolId}, + portalnet::types::{ + content_key::RawContentKey, + messages::{ByteList, Content::Content, ProtocolId}, + }, utp::{ packets::{ExtensionType, Packet, PacketType, HEADER_SIZE}, time::{now_microseconds, Delay, Timestamp}, @@ -107,7 +110,7 @@ struct DelayDifferenceSample { /// and uTP listener pub enum UtpListenerRequest { /// Request to listen for Accept stream - AcceptStream(ConnId, Vec>), + AcceptStream(ConnId, Vec), /// Request to initialize uTP streram with remote node Connect(ConnId, NodeId, oneshot::Sender>), /// Request to listen for FindCOntent stream and send content data diff --git a/trin-core/src/utp/trin_helpers.rs b/trin-core/src/utp/trin_helpers.rs index 2f835faf2..3b434cdaf 100644 --- a/trin-core/src/utp/trin_helpers.rs +++ b/trin-core/src/utp/trin_helpers.rs @@ -1,7 +1,7 @@ #![allow(dead_code)] // These are just some Trin helper functions -use crate::portalnet::types::messages::Content; +use crate::portalnet::types::{content_key::RawContentKey, messages::Content}; use ssz_derive::{Decode, Encode}; // These Utp impl are related to sending messages over uTP not the implementation itself or stream @@ -57,7 +57,7 @@ pub enum UtpStreamId { FindContentStream, FindContentData(Content), OfferStream, - AcceptStream(Vec>), + AcceptStream(Vec), } #[cfg(test)]