Skip to content

do not save non-existing to_address as null address #207

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 9 additions & 15 deletions internal/rpc/serializer.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,21 +167,15 @@ func serializeTransactions(chainId *big.Int, transactions []interface{}, blockTi

func serializeTransaction(chainId *big.Int, tx map[string]interface{}, blockTimestamp time.Time, receipt *common.RawReceipt) common.Transaction {
return common.Transaction{
ChainId: chainId,
Hash: interfaceToString(tx["hash"]),
Nonce: hexToUint64(tx["nonce"]),
BlockHash: interfaceToString(tx["blockHash"]),
BlockNumber: hexToBigInt(tx["blockNumber"]),
BlockTimestamp: blockTimestamp,
TransactionIndex: hexToUint64(tx["transactionIndex"]),
FromAddress: interfaceToString(tx["from"]),
ToAddress: func() string {
to := interfaceToString(tx["to"])
if to != "" {
return to
}
return "0x0000000000000000000000000000000000000000"
}(),
ChainId: chainId,
Hash: interfaceToString(tx["hash"]),
Nonce: hexToUint64(tx["nonce"]),
BlockHash: interfaceToString(tx["blockHash"]),
BlockNumber: hexToBigInt(tx["blockNumber"]),
BlockTimestamp: blockTimestamp,
TransactionIndex: hexToUint64(tx["transactionIndex"]),
FromAddress: interfaceToString(tx["from"]),
ToAddress: interfaceToString(tx["to"]),
Value: hexToBigInt(tx["value"]),
Gas: hexToUint64(tx["gas"]),
GasPrice: hexToBigInt(tx["gasPrice"]),
Expand Down
4 changes: 4 additions & 0 deletions internal/storage/clickhouse.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ type InsertOptions struct {
var DEFAULT_MAX_ROWS_PER_INSERT = 100000
var ZERO_BYTES_66 = strings.Repeat("\x00", 66)
var ZERO_BYTES_10 = strings.Repeat("\x00", 10)
var ZERO_BYTES_42 = strings.Repeat("\x00", 42)

var defaultBlockFields = []string{
"chain_id", "block_number", "hash", "parent_hash", "block_timestamp", "nonce",
Expand Down Expand Up @@ -749,6 +750,9 @@ func scanTransaction(rows driver.Rows) (common.Transaction, error) {
if tx.FunctionSelector == ZERO_BYTES_10 {
tx.FunctionSelector = ""
}
if tx.ToAddress == ZERO_BYTES_42 {
tx.ToAddress = ""
}
return tx, nil
}

Expand Down