mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-23 04:03:49 +00:00
c408281d3b
Co-authored-by: Alex Sharp <alexsharp@Alexs-MacBook-Pro-2.local>
53 lines
1.2 KiB
Go
53 lines
1.2 KiB
Go
package requests
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/ledgerwatch/erigon/cmd/rpctest/rpctest"
|
|
"github.com/ledgerwatch/log/v3"
|
|
)
|
|
|
|
func TxpoolContent(reqId int, logger log.Logger) (int, int, int, error) {
|
|
var (
|
|
b rpctest.EthTxPool
|
|
pending map[string]interface{}
|
|
queued map[string]interface{}
|
|
baseFee map[string]interface{}
|
|
)
|
|
|
|
reqGen := initialiseRequestGenerator(reqId, logger)
|
|
|
|
if res := reqGen.Erigon("txpool_content", reqGen.TxpoolContent(), &b); res.Err != nil {
|
|
return len(pending), len(queued), len(baseFee), fmt.Errorf("failed to fetch txpool content: %v", res.Err)
|
|
}
|
|
|
|
resp := b.Result.(map[string]interface{})
|
|
|
|
pendingLen := 0
|
|
queuedLen := 0
|
|
baseFeeLen := 0
|
|
|
|
if resp["pending"] != nil {
|
|
pending = resp["pending"].(map[string]interface{})
|
|
for _, txs := range pending { // iterate over senders
|
|
pendingLen += len(txs.(map[string]interface{}))
|
|
}
|
|
}
|
|
|
|
if resp["queue"] != nil {
|
|
queued = resp["queue"].(map[string]interface{})
|
|
for _, txs := range queued {
|
|
queuedLen += len(txs.(map[string]interface{}))
|
|
}
|
|
}
|
|
|
|
if resp["baseFee"] != nil {
|
|
baseFee = resp["baseFee"].(map[string]interface{})
|
|
for _, txs := range baseFee {
|
|
baseFeeLen += len(txs.(map[string]interface{}))
|
|
}
|
|
}
|
|
|
|
return pendingLen, queuedLen, baseFeeLen, nil
|
|
}
|