diff --git a/cmd/jsutils/README.md b/cmd/jsutils/README.md index 88efa98dce..30d512860a 100644 --- a/cmd/jsutils/README.md +++ b/cmd/jsutils/README.md @@ -1,7 +1,7 @@ ## Requirement -- nodejs: v20.10.0 -- npm: v10.2.3 +- nodejs >= v16.20.2 +- npm >= v8.19.4 ## Prepare Recommend use [nvm](https://github.com/nvm-sh/nvm) to manage node version. @@ -21,5 +21,5 @@ testnet validators version ``` Transaction count ```bash -node gettxcount.js --rpc ${url} --startNum ${start} --endNum ${end} +node gettxcount.js --rpc ${url} --startNum ${start} --endNum ${end} --miner ${miner} (optional) ``` \ No newline at end of file diff --git a/cmd/jsutils/gettxcount.js b/cmd/jsutils/gettxcount.js index 06ee487881..921f801247 100644 --- a/cmd/jsutils/gettxcount.js +++ b/cmd/jsutils/gettxcount.js @@ -4,6 +4,7 @@ import program from "commander"; program.option("--rpc ", "Rpc"); program.option("--startNum ", "start num") program.option("--endNum ", "end num") +program.option("--miner ", "miner", "") program.parse(process.argv); const provider = new ethers.JsonRpcProvider(program.rpc) @@ -13,13 +14,19 @@ const main = async () => { let num = 0; console.log("Find the max txs count between", program.startNum, "and", program.endNum); for (let i = program.startNum; i < program.endNum; i++) { - let x = await provider.send("eth_getBlockTransactionCountByNumber", [ + if (program.miner !== "") { + let blockData = await provider.getBlock(Number(i)) + if (program.miner !== blockData.miner) { + continue + } + } + let x = await provider.send("eth_getBlockTransactionCountByNumber", [ ethers.toQuantity(i)]); - let a = ethers.toNumber(x) - if (a > txCount) { - num = i; - txCount = a; - } + let a = ethers.toNumber(x) + if (a > txCount) { + num = i; + txCount = a; + } } console.log("BlockNum = ", num, "TxCount =", txCount); };