@@ -427,21 +427,15 @@ type blockStats struct {
427
427
GasLimit * big.Int `json:"gasLimit"`
428
428
Diff string `json:"difficulty"`
429
429
TotalDiff string `json:"totalDifficulty"`
430
- Txs txStats `json:"transactions"`
430
+ Txs [] txStats `json:"transactions"`
431
431
TxHash common.Hash `json:"transactionsRoot"`
432
432
Root common.Hash `json:"stateRoot"`
433
433
Uncles uncleStats `json:"uncles"`
434
434
}
435
435
436
- // txStats is a custom wrapper around a transaction array to force serializing
437
- // empty arrays instead of returning null for them.
438
- type txStats []* types.Transaction
439
-
440
- func (s txStats ) MarshalJSON () ([]byte , error ) {
441
- if txs := ([]* types.Transaction )(s ); len (txs ) > 0 {
442
- return json .Marshal (txs )
443
- }
444
- return []byte ("[]" ), nil
436
+ // txStats is the information to report about individual transactions.
437
+ type txStats struct {
438
+ Hash common.Hash `json:"hash"`
445
439
}
446
440
447
441
// uncleStats is a custom wrapper around an uncle array to force serializing
@@ -480,7 +474,7 @@ func (s *Service) assembleBlockStats(block *types.Block) *blockStats {
480
474
var (
481
475
header * types.Header
482
476
td * big.Int
483
- txs []* types. Transaction
477
+ txs []txStats
484
478
uncles []* types.Header
485
479
)
486
480
if s .eth != nil {
@@ -491,7 +485,10 @@ func (s *Service) assembleBlockStats(block *types.Block) *blockStats {
491
485
header = block .Header ()
492
486
td = s .eth .BlockChain ().GetTd (header .Hash (), header .Number .Uint64 ())
493
487
494
- txs = block .Transactions ()
488
+ txs = make ([]txStats , len (block .Transactions ()))
489
+ for i , tx := range block .Transactions () {
490
+ txs [i ].Hash = tx .Hash ()
491
+ }
495
492
uncles = block .Uncles ()
496
493
} else {
497
494
// Light nodes would need on-demand lookups for transactions/uncles, skip
@@ -501,6 +498,7 @@ func (s *Service) assembleBlockStats(block *types.Block) *blockStats {
501
498
header = s .les .BlockChain ().CurrentHeader ()
502
499
}
503
500
td = s .les .BlockChain ().GetTd (header .Hash (), header .Number .Uint64 ())
501
+ txs = []txStats {}
504
502
}
505
503
// Assemble and return the block stats
506
504
author , _ := s .engine .Author (header )
0 commit comments