erigon-pulse/cmd/devnet/requests/tx.go
Leonard Chinonso 805230ba63
Setup web socket endpoints to listen for new transactions after sending (#5940)
- Added listening methods for WebSocket subscriptions 
- Listened for new blocks using the newHeads method to determine when to
look for a transaction
- Added new util methods and tests for them
- Simplified communication to the user upon initiating the devnet tool
2022-11-03 09:45:36 +07:00

40 lines
967 B
Go

package requests
import (
"fmt"
"github.com/ledgerwatch/erigon/cmd/devnet/devnetutils"
"github.com/ledgerwatch/erigon/cmd/rpctest/rpctest"
)
func TxpoolContent(reqId int) (int, int, error) {
var (
b rpctest.EthTxPool
pending map[string]interface{}
queued map[string]interface{}
)
reqGen := initialiseRequestGenerator(reqId)
if res := reqGen.Erigon("txpool_content", reqGen.TxpoolContent(), &b); res.Err != nil {
return len(pending), len(queued), fmt.Errorf("failed to fetch txpool content: %v", res.Err)
}
resp := b.Result.(map[string]interface{})
s, err := devnetutils.ParseResponse(b)
if err != nil {
return len(pending), len(queued), fmt.Errorf("error parsing resonse: %v", err)
}
if resp["pending"] != nil {
pending = resp["pending"].(map[string]interface{})
}
if resp["queue"] != nil {
queued = resp["queue"].(map[string]interface{})
}
fmt.Printf("Txpool content: %v\n", s)
return len(pending), len(queued), nil
}