@@ -60,7 +60,8 @@ impl LightEthereumBlockExt for LightEthereumBlock {
60
60
impl < ' a > From < & ' a EthereumBlockType > for LightEthereumBlock {
61
61
fn from ( block : & ' a EthereumBlockType ) -> LightEthereumBlock {
62
62
match block {
63
- EthereumBlockType :: Full ( block) => block. block . clone ( ) ,
63
+ EthereumBlockType :: FullWithReceipts ( block) => block. block . clone ( ) ,
64
+ EthereumBlockType :: Full ( block) => block. clone ( ) ,
64
65
EthereumBlockType :: Light ( block) => block. clone ( ) ,
65
66
}
66
67
}
@@ -207,7 +208,9 @@ impl Eq for EthereumTrigger {}
207
208
pub enum EthereumBlockType {
208
209
Light ( LightEthereumBlock ) ,
209
210
210
- Full ( EthereumBlock ) ,
211
+ Full ( LightEthereumBlock ) ,
212
+
213
+ FullWithReceipts ( EthereumBlock ) ,
211
214
}
212
215
213
216
impl Default for EthereumBlockType {
@@ -216,16 +219,17 @@ impl Default for EthereumBlockType {
216
219
}
217
220
}
218
221
219
- impl < ' a > From < & ' a LightEthereumBlock > for EthereumBlockType {
220
- fn from ( block : & ' a LightEthereumBlock ) -> EthereumBlockType {
221
- EthereumBlockType :: Light ( block. clone ( ) )
222
- }
223
- }
224
-
225
- #[ derive( Clone , Debug , PartialEq , Eq ) ]
222
+ #[ derive( Clone , Copy , Debug , PartialEq , Eq ) ]
226
223
pub enum BlockType {
227
224
Light ,
228
225
Full ,
226
+ FullWithReceipts ,
227
+ }
228
+
229
+ impl Default for BlockType {
230
+ fn default ( ) -> BlockType {
231
+ BlockType :: Light
232
+ }
229
233
}
230
234
231
235
#[ derive( Clone , Debug , PartialEq , Eq ) ]
@@ -317,7 +321,7 @@ pub struct EthereumTransactionReceiptData {
317
321
pub input : Bytes ,
318
322
}
319
323
320
- pub struct FullEthereumBlockData {
324
+ pub struct FullEthereumBlockDataWithReceipts {
321
325
pub hash : H256 ,
322
326
pub parent_hash : H256 ,
323
327
pub uncles_hash : H256 ,
@@ -335,14 +339,17 @@ pub struct FullEthereumBlockData {
335
339
pub transaction_receipts : Vec < EthereumTransactionReceiptData > ,
336
340
}
337
341
338
- impl < ' a > TryFrom < & ' a EthereumBlockType > for FullEthereumBlockData {
342
+ impl < ' a > TryFrom < & ' a EthereumBlockType > for FullEthereumBlockDataWithReceipts {
339
343
type Error = String ;
340
344
341
- fn try_from ( block : & ' a EthereumBlockType ) -> Result < FullEthereumBlockData , Self :: Error > {
345
+ fn try_from ( block : & ' a EthereumBlockType ) -> Result < FullEthereumBlockDataWithReceipts , Self :: Error > {
342
346
let fullblock = match block {
343
- EthereumBlockType :: Full ( full_block) => full_block,
347
+ EthereumBlockType :: FullWithReceipts ( full_block) => full_block,
348
+ EthereumBlockType :: Full ( _) => return Err ( format ! (
349
+ "Failed to convert EthereumBlockType to FullEthereumBlockDataWithReceipts, requires a EthereumBlockType::FullWithReceipts()"
350
+ ) ) ,
344
351
EthereumBlockType :: Light ( _) => return Err ( format ! (
345
- "Failed to convert EthereumBlockType to FUllEthereumBlockData , requires a EthereumBlockType::Full ()"
352
+ "Failed to convert EthereumBlockType to FullEthereumBlockDataWithReceipts , requires a EthereumBlockType::FullWithReceipts ()"
346
353
) )
347
354
} ;
348
355
let block = & fullblock. block ;
@@ -376,7 +383,7 @@ impl<'a> TryFrom<&'a EthereumBlockType> for FullEthereumBlockData {
376
383
} )
377
384
. collect :: < Vec < EthereumTransactionReceiptData > > ( ) ;
378
385
379
- Ok ( FullEthereumBlockData {
386
+ Ok ( FullEthereumBlockDataWithReceipts {
380
387
hash : block. hash . unwrap ( ) ,
381
388
parent_hash : block. parent_hash ,
382
389
uncles_hash : block. uncles_hash ,
@@ -396,8 +403,8 @@ impl<'a> TryFrom<&'a EthereumBlockType> for FullEthereumBlockData {
396
403
}
397
404
}
398
405
399
- impl < ' a > From < & ' a EthereumBlock > for FullEthereumBlockData {
400
- fn from ( block : & ' a EthereumBlock ) -> FullEthereumBlockData {
406
+ impl < ' a > From < & ' a EthereumBlock > for FullEthereumBlockDataWithReceipts {
407
+ fn from ( block : & ' a EthereumBlock ) -> FullEthereumBlockDataWithReceipts {
401
408
let transaction_receipts_data = block
402
409
. block
403
410
. transactions
@@ -430,7 +437,7 @@ impl<'a> From<&'a EthereumBlock> for FullEthereumBlockData {
430
437
. collect :: < Vec < EthereumTransactionReceiptData > > ( ) ;
431
438
let block = & block. block ;
432
439
433
- FullEthereumBlockData {
440
+ FullEthereumBlockDataWithReceipts {
434
441
hash : block. hash . unwrap ( ) ,
435
442
parent_hash : block. parent_hash ,
436
443
uncles_hash : block. uncles_hash ,
@@ -452,7 +459,7 @@ impl<'a> From<&'a EthereumBlock> for FullEthereumBlockData {
452
459
453
460
/// Ethereum block data.
454
461
#[ derive( Clone , Debug , Default ) ]
455
- pub struct EthereumBlockData {
462
+ pub struct FullEthereumBlockData {
456
463
pub hash : H256 ,
457
464
pub parent_hash : H256 ,
458
465
pub uncles_hash : H256 ,
@@ -470,9 +477,9 @@ pub struct EthereumBlockData {
470
477
pub transactions : Vec < EthereumTransactionData > ,
471
478
}
472
479
473
- impl < ' a > From < & ' a LightEthereumBlock > for EthereumBlockData {
474
- fn from ( block : & ' a LightEthereumBlock ) -> EthereumBlockData {
475
- EthereumBlockData {
480
+ impl < ' a > From < & ' a LightEthereumBlock > for FullEthereumBlockData {
481
+ fn from ( block : & ' a LightEthereumBlock ) -> FullEthereumBlockData {
482
+ FullEthereumBlockData {
476
483
hash : block. hash . unwrap ( ) ,
477
484
parent_hash : block. parent_hash ,
478
485
uncles_hash : block. uncles_hash ,
@@ -496,14 +503,15 @@ impl<'a> From<&'a LightEthereumBlock> for EthereumBlockData {
496
503
}
497
504
}
498
505
499
- impl < ' a > From < & ' a EthereumBlockType > for EthereumBlockData {
500
- fn from ( block : & ' a EthereumBlockType ) -> EthereumBlockData {
506
+ impl < ' a > From < & ' a EthereumBlockType > for FullEthereumBlockData {
507
+ fn from ( block : & ' a EthereumBlockType ) -> FullEthereumBlockData {
501
508
let block = match block {
502
- EthereumBlockType :: Full ( full_block) => & full_block. block ,
509
+ EthereumBlockType :: FullWithReceipts ( full_block) => & full_block. block ,
510
+ EthereumBlockType :: Full ( block) => & block,
503
511
EthereumBlockType :: Light ( light_block) => light_block,
504
512
} ;
505
513
506
- EthereumBlockData {
514
+ FullEthereumBlockData {
507
515
hash : block. hash . unwrap ( ) ,
508
516
parent_hash : block. parent_hash ,
509
517
uncles_hash : block. uncles_hash ,
@@ -527,6 +535,73 @@ impl<'a> From<&'a EthereumBlockType> for EthereumBlockData {
527
535
}
528
536
}
529
537
538
+ /// Ethereum block data.
539
+ #[ derive( Clone , Debug , Default ) ]
540
+ pub struct EthereumBlockData {
541
+ pub hash : H256 ,
542
+ pub parent_hash : H256 ,
543
+ pub uncles_hash : H256 ,
544
+ pub author : H160 ,
545
+ pub state_root : H256 ,
546
+ pub transactions_root : H256 ,
547
+ pub receipts_root : H256 ,
548
+ pub number : U64 ,
549
+ pub gas_used : U256 ,
550
+ pub gas_limit : U256 ,
551
+ pub timestamp : U256 ,
552
+ pub difficulty : U256 ,
553
+ pub total_difficulty : U256 ,
554
+ pub size : Option < U256 > ,
555
+ }
556
+
557
+ impl < ' a > From < & ' a LightEthereumBlock > for EthereumBlockData {
558
+ fn from ( block : & ' a LightEthereumBlock ) -> EthereumBlockData {
559
+ EthereumBlockData {
560
+ hash : block. hash . unwrap ( ) ,
561
+ parent_hash : block. parent_hash ,
562
+ uncles_hash : block. uncles_hash ,
563
+ author : block. author ,
564
+ state_root : block. state_root ,
565
+ transactions_root : block. transactions_root ,
566
+ receipts_root : block. receipts_root ,
567
+ number : block. number . unwrap ( ) ,
568
+ gas_used : block. gas_used ,
569
+ gas_limit : block. gas_limit ,
570
+ timestamp : block. timestamp ,
571
+ difficulty : block. difficulty ,
572
+ total_difficulty : block. total_difficulty . unwrap_or_default ( ) ,
573
+ size : block. size ,
574
+ }
575
+ }
576
+ }
577
+
578
+ impl < ' a > From < & ' a EthereumBlockType > for EthereumBlockData {
579
+ fn from ( block : & ' a EthereumBlockType ) -> EthereumBlockData {
580
+ let block = match block {
581
+ EthereumBlockType :: FullWithReceipts ( full_block) => & full_block. block ,
582
+ EthereumBlockType :: Full ( full_block) => & full_block,
583
+ EthereumBlockType :: Light ( light_block) => light_block,
584
+ } ;
585
+
586
+ EthereumBlockData {
587
+ hash : block. hash . unwrap ( ) ,
588
+ parent_hash : block. parent_hash ,
589
+ uncles_hash : block. uncles_hash ,
590
+ author : block. author ,
591
+ state_root : block. state_root ,
592
+ transactions_root : block. transactions_root ,
593
+ receipts_root : block. receipts_root ,
594
+ number : block. number . unwrap ( ) ,
595
+ gas_used : block. gas_used ,
596
+ gas_limit : block. gas_limit ,
597
+ timestamp : block. timestamp ,
598
+ difficulty : block. difficulty ,
599
+ total_difficulty : block. total_difficulty . unwrap_or_default ( ) ,
600
+ size : block. size ,
601
+ }
602
+ }
603
+ }
604
+
530
605
/// Ethereum transaction data.
531
606
#[ derive( Clone , Debug ) ]
532
607
pub struct EthereumTransactionData {
0 commit comments