Skip to content

Commit e96f298

Browse files
authored
Merge pull request #14548 from karalabe/ethstats-no-txs
ethstats: don't report transaction content, only hash
2 parents dd06c85 + 09d59da commit e96f298

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

ethstats/ethstats.go

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -427,21 +427,15 @@ type blockStats struct {
427427
GasLimit *big.Int `json:"gasLimit"`
428428
Diff string `json:"difficulty"`
429429
TotalDiff string `json:"totalDifficulty"`
430-
Txs txStats `json:"transactions"`
430+
Txs []txStats `json:"transactions"`
431431
TxHash common.Hash `json:"transactionsRoot"`
432432
Root common.Hash `json:"stateRoot"`
433433
Uncles uncleStats `json:"uncles"`
434434
}
435435

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"`
445439
}
446440

447441
// uncleStats is a custom wrapper around an uncle array to force serializing
@@ -480,7 +474,7 @@ func (s *Service) assembleBlockStats(block *types.Block) *blockStats {
480474
var (
481475
header *types.Header
482476
td *big.Int
483-
txs []*types.Transaction
477+
txs []txStats
484478
uncles []*types.Header
485479
)
486480
if s.eth != nil {
@@ -491,7 +485,10 @@ func (s *Service) assembleBlockStats(block *types.Block) *blockStats {
491485
header = block.Header()
492486
td = s.eth.BlockChain().GetTd(header.Hash(), header.Number.Uint64())
493487

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+
}
495492
uncles = block.Uncles()
496493
} else {
497494
// Light nodes would need on-demand lookups for transactions/uncles, skip
@@ -501,6 +498,7 @@ func (s *Service) assembleBlockStats(block *types.Block) *blockStats {
501498
header = s.les.BlockChain().CurrentHeader()
502499
}
503500
td = s.les.BlockChain().GetTd(header.Hash(), header.Number.Uint64())
501+
txs = []txStats{}
504502
}
505503
// Assemble and return the block stats
506504
author, _ := s.engine.Author(header)

0 commit comments

Comments
 (0)