@@ -200,6 +200,7 @@ pub enum EthereumBlockType {
200200
201201 FullWithReceipts ( EthereumBlock ) ,
202202}
203+
203204impl EthereumBlockType {
204205 pub fn light_block ( & self ) -> & LightEthereumBlock {
205206 match self {
@@ -217,26 +218,22 @@ impl EthereumBlockType {
217218 self . light_block ( ) . number . unwrap ( ) . as_u64 ( )
218219 }
219220
220- pub fn transaction_for_log ( & self , log : & Log ) -> Option < Transaction > {
221- log. transaction_hash
222- . and_then ( |hash| {
223- self . light_block ( )
224- . transactions
225- . iter ( )
226- . find ( |tx| tx. hash == hash)
227- } )
228- . cloned ( )
221+ pub fn transaction_for_log ( & self , log : & Log ) -> Option < & Transaction > {
222+ log. transaction_hash . and_then ( |hash| {
223+ self . light_block ( )
224+ . transactions
225+ . iter ( )
226+ . find ( |tx| tx. hash == hash)
227+ } )
229228 }
230229
231- pub fn transaction_for_call ( & self , call : & EthereumCall ) -> Option < Transaction > {
232- call. transaction_hash
233- . and_then ( |hash| {
234- self . light_block ( )
235- . transactions
236- . iter ( )
237- . find ( |tx| tx. hash == hash)
238- } )
239- . cloned ( )
230+ pub fn transaction_for_call ( & self , call : & EthereumCall ) -> Option < & Transaction > {
231+ call. transaction_hash . and_then ( |hash| {
232+ self . light_block ( )
233+ . transactions
234+ . iter ( )
235+ . find ( |tx| tx. hash == hash)
236+ } )
240237 }
241238}
242239
@@ -259,8 +256,8 @@ impl Default for BlockType {
259256 }
260257}
261258
262- impl < ' a > From < & ' a EthereumBlockHandlerData > for BlockType {
263- fn from ( block : & ' a EthereumBlockHandlerData ) -> BlockType {
259+ impl From < EthereumBlockHandlerData > for BlockType {
260+ fn from ( block : EthereumBlockHandlerData ) -> BlockType {
264261 match block {
265262 EthereumBlockHandlerData :: Block => BlockType :: Light ,
266263 EthereumBlockHandlerData :: FullBlock => BlockType :: Full ,
@@ -364,6 +361,7 @@ pub struct EthereumTransactionReceiptData {
364361 pub input : Bytes ,
365362}
366363
364+ /// Ethereum block data with transactions and their receipts.
367365pub struct FullEthereumBlockDataWithReceipts {
368366 pub hash : H256 ,
369367 pub parent_hash : H256 ,
@@ -443,18 +441,15 @@ impl<'a> TryFrom<&'a EthereumBlockType> for FullEthereumBlockDataWithReceipts {
443441 ) -> Result < FullEthereumBlockDataWithReceipts , Self :: Error > {
444442 let fullblock = match block {
445443 EthereumBlockType :: FullWithReceipts ( full_block) => full_block,
446- EthereumBlockType :: Full ( _) => return Err ( anyhow:: anyhow!(
444+ EthereumBlockType :: Full ( _) | EthereumBlockType :: Light ( _ ) => return Err ( anyhow:: anyhow!(
447445 "Failed to convert EthereumBlockType to FullEthereumBlockDataWithReceipts, requires an EthereumBlockType::FullWithReceipts()"
448446 ) ) ,
449- EthereumBlockType :: Light ( _) => return Err ( anyhow:: anyhow!(
450- "Failed to convert EthereumBlockType to FullEthereumBlockDataWithReceipts, requires an EthereumBlockType::FullWithReceipts()"
451- ) )
452447 } ;
453448 Ok ( fullblock. into ( ) )
454449 }
455450}
456451
457- /// Ethereum block data.
452+ /// Ethereum block data with transactions .
458453#[ derive( Clone , Debug , Default ) ]
459454pub struct FullEthereumBlockData {
460455 pub hash : H256 ,
0 commit comments