mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-25 13:07:17 +00:00
805230ba63
- 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
40 lines
967 B
Go
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
|
|
}
|