mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2025-01-08 03:51:20 +00:00
415cf86250
This branch is intended to allow the devnet to be used for testing multiple consents types beyond the default clique. It is initially being used to test Bor consensus for polygon. It also has the following refactoring: ### 1. Network configuration The two node arg building functions miningNodeArgs and nonMiningNodeArgs have been replaced with a configuration struct which is used to configure: ```go network := &node.Network{ DataDir: dataDir, Chain: networkname.DevChainName, //Chain: networkname.BorDevnetChainName, Logger: logger, BasePrivateApiAddr: "localhost:9090", BaseRPCAddr: "localhost:8545", Nodes: []node.NetworkNode{ &node.Miner{}, &node.NonMiner{}, }, } ``` and start multiple nodes ```go network.Start() ``` Network start will create a network of nodes ensuring that all nodes are configured with non clashing network ports set via command line arguments on start-up. ### 2. Request Routing The `RequestRouter` has been updated to take a 'target' rather than using a static dispatcher which routes to a single node on the network. Each node in the network has its own request generator so command and services have more flexibility in request routing and `ExecuteAllMethods` currently takes the `node.Network` as an argument and can pick which node (node 0 for the moment) to send requests to.
59 lines
1.4 KiB
Go
59 lines
1.4 KiB
Go
package requests
|
|
|
|
import (
|
|
"fmt"
|
|
)
|
|
|
|
type EthTxPool struct {
|
|
CommonResponse
|
|
Result interface{} `json:"result"`
|
|
}
|
|
|
|
func (reqGen *RequestGenerator) TxpoolContent() (int, int, int, error) {
|
|
var (
|
|
b EthTxPool
|
|
pending map[string]interface{}
|
|
queued map[string]interface{}
|
|
baseFee map[string]interface{}
|
|
)
|
|
|
|
method, body := reqGen.txpoolContent()
|
|
if res := reqGen.call(method, body, &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
|
|
}
|
|
|
|
func (req *RequestGenerator) txpoolContent() (RPCMethod, string) {
|
|
const template = `{"jsonrpc":"2.0","method":%q,"params":[],"id":%d}`
|
|
return Methods.TxpoolContent, fmt.Sprintf(template, Methods.TxpoolContent, req.reqID)
|
|
}
|