From 5b45b957279e0dba4cb948c94d65b1fb1541b710 Mon Sep 17 00:00:00 2001 From: Neeraj Kashyap Date: Wed, 18 Aug 2021 12:30:03 -0700 Subject: [PATCH] Fixed JSON marshalling for PendingTransaction Changed `Transaction` to `interface{}` because the Ethereum `types.Transaction` struct does not have `json` annotations and so it was serializing as an empty `{}`. --- crawlers/ethtxpool/.gitignore | 1 + crawlers/ethtxpool/main.go | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) create mode 100644 crawlers/ethtxpool/.gitignore diff --git a/crawlers/ethtxpool/.gitignore b/crawlers/ethtxpool/.gitignore new file mode 100644 index 00000000..8d5279b9 --- /dev/null +++ b/crawlers/ethtxpool/.gitignore @@ -0,0 +1 @@ +.secrets/ diff --git a/crawlers/ethtxpool/main.go b/crawlers/ethtxpool/main.go index fb66e933..b70a9eb4 100644 --- a/crawlers/ethtxpool/main.go +++ b/crawlers/ethtxpool/main.go @@ -23,9 +23,9 @@ func humbugClientFromEnv() (*humbug.HumbugReporter, error) { } type PendingTransaction struct { - From string `json:"from"` - Nonce uint64 `json:"nonce"` - Transaction types.Transaction `json:"transaction"` + From string `json:"from"` + Nonce uint64 `json:"nonce"` + Transaction interface{} `json:"transaction"` } var ReportTitle string = "Ethereum: Pending transaction" @@ -50,7 +50,7 @@ func main() { pendingTransactions := result["pending"] for fromAddress, transactionsByNonce := range pendingTransactions { for nonce, transaction := range transactionsByNonce { - pendingTx := PendingTransaction{From: fromAddress, Nonce: nonce, Transaction: *transaction} + pendingTx := PendingTransaction{From: fromAddress, Nonce: nonce, Transaction: transaction} contents, jsonErr := json.Marshal(pendingTx) if jsonErr != nil { fmt.Fprintf(os.Stderr, "Error marshalling pending transaction to JSON:\n%v\n", pendingTx)