Skip to content

Commit 03864f8

Browse files
committed
do not save non-existing to_address as null address
1 parent 92af676 commit 03864f8

File tree

2 files changed

+13
-15
lines changed

2 files changed

+13
-15
lines changed

internal/rpc/serializer.go

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -167,21 +167,15 @@ func serializeTransactions(chainId *big.Int, transactions []interface{}, blockTi
167167

168168
func serializeTransaction(chainId *big.Int, tx map[string]interface{}, blockTimestamp time.Time, receipt *common.RawReceipt) common.Transaction {
169169
return common.Transaction{
170-
ChainId: chainId,
171-
Hash: interfaceToString(tx["hash"]),
172-
Nonce: hexToUint64(tx["nonce"]),
173-
BlockHash: interfaceToString(tx["blockHash"]),
174-
BlockNumber: hexToBigInt(tx["blockNumber"]),
175-
BlockTimestamp: blockTimestamp,
176-
TransactionIndex: hexToUint64(tx["transactionIndex"]),
177-
FromAddress: interfaceToString(tx["from"]),
178-
ToAddress: func() string {
179-
to := interfaceToString(tx["to"])
180-
if to != "" {
181-
return to
182-
}
183-
return "0x0000000000000000000000000000000000000000"
184-
}(),
170+
ChainId: chainId,
171+
Hash: interfaceToString(tx["hash"]),
172+
Nonce: hexToUint64(tx["nonce"]),
173+
BlockHash: interfaceToString(tx["blockHash"]),
174+
BlockNumber: hexToBigInt(tx["blockNumber"]),
175+
BlockTimestamp: blockTimestamp,
176+
TransactionIndex: hexToUint64(tx["transactionIndex"]),
177+
FromAddress: interfaceToString(tx["from"]),
178+
ToAddress: interfaceToString(tx["to"]),
185179
Value: hexToBigInt(tx["value"]),
186180
Gas: hexToUint64(tx["gas"]),
187181
GasPrice: hexToBigInt(tx["gasPrice"]),

internal/storage/clickhouse.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ type InsertOptions struct {
3232
var DEFAULT_MAX_ROWS_PER_INSERT = 100000
3333
var ZERO_BYTES_66 = strings.Repeat("\x00", 66)
3434
var ZERO_BYTES_10 = strings.Repeat("\x00", 10)
35+
var ZERO_BYTES_42 = strings.Repeat("\x00", 42)
3536

3637
var defaultBlockFields = []string{
3738
"chain_id", "block_number", "hash", "parent_hash", "block_timestamp", "nonce",
@@ -749,6 +750,9 @@ func scanTransaction(rows driver.Rows) (common.Transaction, error) {
749750
if tx.FunctionSelector == ZERO_BYTES_10 {
750751
tx.FunctionSelector = ""
751752
}
753+
if tx.ToAddress == ZERO_BYTES_42 {
754+
tx.ToAddress = ""
755+
}
752756
return tx, nil
753757
}
754758

0 commit comments

Comments
 (0)