Skip to content

Commit f796421

Browse files
committed
Move bloom optimization to only RPC return
1 parent 850a712 commit f796421

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

core/types/bloom9.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,10 @@ func (b *Bloom) ProtoDecode(data []byte) error {
124124
return nil
125125
}
126126

127+
func (b Bloom) CheckAllZeros() bool {
128+
return b == Bloom{}
129+
}
130+
127131
// CreateBloom creates a bloom filter out of the give Receipts (+Logs)
128132
func CreateBloom(receipts Receipts) Bloom {
129133
buf := make([]byte, 6)

internal/quaiapi/api.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1301,10 +1301,15 @@ func (s *PublicBlockChainAPI) GetTransactionReceipt(ctx context.Context, hash co
13011301
"cumulativeGasUsed": hexutil.Uint64(receipt.CumulativeGasUsed),
13021302
"contractAddress": nil,
13031303
"logs": receipt.Logs,
1304-
"logsBloom": receipt.Bloom.ToLegacyBloom(),
13051304
"type": hexutil.Uint(tx.Type()),
13061305
}
13071306

1307+
if receipt.Bloom.CheckAllZeros() {
1308+
fields["logsBloom"] = nil
1309+
} else {
1310+
fields["logsBloom"] = receipt.Bloom.ToLegacyBloom()
1311+
}
1312+
13081313
if tx.Type() == types.QuaiTxType {
13091314
if to := tx.To(); to != nil {
13101315
fields["to"] = to.Hex()

internal/quaiapi/quai_api.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1457,10 +1457,15 @@ func (s *PublicBlockChainQuaiAPI) GetTransactionReceipt(ctx context.Context, has
14571457
"cumulativeGasUsed": hexutil.Uint64(receipt.CumulativeGasUsed),
14581458
"contractAddress": nil,
14591459
"logs": receipt.Logs,
1460-
"logsBloom": receipt.Bloom,
14611460
"type": hexutil.Uint(tx.Type()),
14621461
}
14631462

1463+
if receipt.Bloom.CheckAllZeros() {
1464+
fields["logsBloom"] = nil
1465+
} else {
1466+
fields["logsBloom"] = receipt.Bloom
1467+
}
1468+
14641469
if tx.Type() == types.QuaiTxType {
14651470
if to := tx.To(); to != nil {
14661471
fields["to"] = to.Hex()

0 commit comments

Comments
 (0)