@@ -200,6 +200,7 @@ pub enum EthereumBlockType {
200
200
201
201
FullWithReceipts ( EthereumBlock ) ,
202
202
}
203
+
203
204
impl EthereumBlockType {
204
205
pub fn light_block ( & self ) -> & LightEthereumBlock {
205
206
match self {
@@ -217,26 +218,22 @@ impl EthereumBlockType {
217
218
self . light_block ( ) . number . unwrap ( ) . as_u64 ( )
218
219
}
219
220
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
+ } )
229
228
}
230
229
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
+ } )
240
237
}
241
238
}
242
239
@@ -259,8 +256,8 @@ impl Default for BlockType {
259
256
}
260
257
}
261
258
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 {
264
261
match block {
265
262
EthereumBlockHandlerData :: Block => BlockType :: Light ,
266
263
EthereumBlockHandlerData :: FullBlock => BlockType :: Full ,
@@ -364,6 +361,7 @@ pub struct EthereumTransactionReceiptData {
364
361
pub input : Bytes ,
365
362
}
366
363
364
+ /// Ethereum block data with transactions and their receipts.
367
365
pub struct FullEthereumBlockDataWithReceipts {
368
366
pub hash : H256 ,
369
367
pub parent_hash : H256 ,
@@ -443,18 +441,15 @@ impl<'a> TryFrom<&'a EthereumBlockType> for FullEthereumBlockDataWithReceipts {
443
441
) -> Result < FullEthereumBlockDataWithReceipts , Self :: Error > {
444
442
let fullblock = match block {
445
443
EthereumBlockType :: FullWithReceipts ( full_block) => full_block,
446
- EthereumBlockType :: Full ( _) => return Err ( anyhow:: anyhow!(
444
+ EthereumBlockType :: Full ( _) | EthereumBlockType :: Light ( _ ) => return Err ( anyhow:: anyhow!(
447
445
"Failed to convert EthereumBlockType to FullEthereumBlockDataWithReceipts, requires an EthereumBlockType::FullWithReceipts()"
448
446
) ) ,
449
- EthereumBlockType :: Light ( _) => return Err ( anyhow:: anyhow!(
450
- "Failed to convert EthereumBlockType to FullEthereumBlockDataWithReceipts, requires an EthereumBlockType::FullWithReceipts()"
451
- ) )
452
447
} ;
453
448
Ok ( fullblock. into ( ) )
454
449
}
455
450
}
456
451
457
- /// Ethereum block data.
452
+ /// Ethereum block data with transactions .
458
453
#[ derive( Clone , Debug , Default ) ]
459
454
pub struct FullEthereumBlockData {
460
455
pub hash : H256 ,
0 commit comments