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 `{}`.
pull/138/head
Neeraj Kashyap 2021-08-18 12:30:03 -07:00
rodzic 15d0836353
commit 5b45b95727
2 zmienionych plików z 5 dodań i 4 usunięć

1
crawlers/ethtxpool/.gitignore vendored 100644
Wyświetl plik

@ -0,0 +1 @@
.secrets/

Wyświetl plik

@ -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)