@@ -107,6 +107,22 @@ impl BlobTransactionSidecarVariant {
107107 VersionedHashIter :: new ( self . commitments ( ) )
108108 }
109109
110+ /// Returns the index of the versioned hash in the commitments vector.
111+ pub fn versioned_hash_index ( & self , hash : & B256 ) -> Option < usize > {
112+ match self {
113+ Self :: Eip4844 ( s) => s. versioned_hash_index ( hash) ,
114+ Self :: Eip7594 ( s) => s. versioned_hash_index ( hash) ,
115+ }
116+ }
117+
118+ /// Returns the blob corresponding to the versioned hash, if it exists.
119+ pub fn blob_by_versioned_hash ( & self , hash : & B256 ) -> Option < & Blob > {
120+ match self {
121+ Self :: Eip4844 ( s) => s. blob_by_versioned_hash ( hash) ,
122+ Self :: Eip7594 ( s) => s. blob_by_versioned_hash ( hash) ,
123+ }
124+ }
125+
110126 /// Outputs the RLP length of the [BlobTransactionSidecarVariant] fields, without a RLP header.
111127 #[ doc( hidden) ]
112128 pub fn rlp_encoded_fields_length ( & self ) -> usize {
@@ -414,6 +430,18 @@ impl BlobTransactionSidecarEip7594 {
414430 VersionedHashIter :: new ( & self . commitments )
415431 }
416432
433+ /// Returns the index of the versioned hash in the commitments vector.
434+ pub fn versioned_hash_index ( & self , hash : & B256 ) -> Option < usize > {
435+ self . commitments . iter ( ) . position ( |commitment| {
436+ crate :: eip4844:: kzg_to_versioned_hash ( commitment. as_slice ( ) ) == * hash
437+ } )
438+ }
439+
440+ /// Returns the blob corresponding to the versioned hash, if it exists.
441+ pub fn blob_by_versioned_hash ( & self , hash : & B256 ) -> Option < & Blob > {
442+ self . versioned_hash_index ( hash) . and_then ( |index| self . blobs . get ( index) )
443+ }
444+
417445 /// Matches versioned hashes and returns an iterator of (index, [`BlobAndProofV2`]) pairs
418446 /// where index is the position in `versioned_hashes` that matched the versioned hash in the
419447 /// sidecar.
0 commit comments