Open
Description
Instead of using Vec<u8>
to represent raw content keys/values, we should use something like alloy_primitives::Bytes
because:
- copy is faster
- (de)serializes into hex string correctly
We should either wrap or name the type, to avoid potential confusion (e.g. see RawContentValue
).
Other places that should be updated:
- ethportal-api/src/types/portal_wire.rs
-
FindContent::content_key
- type should beRawContentKey
-
Content::Content(Vec<u8>)
->Content::Content(RawContentValue)
-
PopulatedOffer::content
items - type should beVec<(RawContentKey, RawContentValue)>
- same with
PopulatedOfferWithResult
- same with
-
- portalnet/src/find/query_info.rs
-
RecursiveFindContentResult
- should beRawContentValue
instead ofVec<u8>
-
- portalnet/src/find/iterators/findcontent.rs
-
FindContentQueryResponse::Content
- should beRawContentValue
-
FindContentQueryPending::PendingContent.content
- should beRawContentValue
-
UnvalidatedContent::Content
- should beRawContentValue
-
ValidatedContent.content
- should beRawContentValue
-
- portalnet/src/overlay/protocol.rs and portalnet/src/overlay/service.rs
- several functions (but not all) accept or return
Vec<u8>
, when it should be eitherRawContentKey
orRawContentValue
- several functions (but not all) accept or return
- portalnet/src/utp_controller.rs
- all functions should accept/return
bytes::Bytes
instead ofVec<u8>
- all functions should accept/return
- portalnet/src/utils/portal_wire.rs
-
decode_content_payload
- should accept and returnbytes::Bytes
-
- portalnet/src/discovery.rs
-
ProtocolRequest
- should bebytes::Bytes
-
send_talk_req
- should returnbytes::Bytes
-
- portalnet/src/gossip.rs
- both
propagate_gossip_cross_thread
andtrace_propagate_gossip_cross_thread
should acceptRawContentValue
instead ofVec<u8>
- both
- trin-storage/src/lib.rs
-
ContentStore::get
- should returnResult<Option<RawContentValue>>
-
ContentStore::put
- should returnResult<Vec<(Self::Key, RawContentValue)>, ContentStoreError>
- all implementations of
ContentStore
should be updated as well
-
Activity