Skip to content

Commit

Permalink
cmd/jsutils: add utils
Browse files Browse the repository at this point in the history
  • Loading branch information
zlacfzy committed Dec 7, 2023
1 parent 15bebb3 commit 5c37a35
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions cmd/jsutils/gettxsbyrang.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { ethers } from "ethers";
import program from "commander";

// program.option("--Rpc <Rpc>", "Rpc");
// program.option("--StartNum <StartNum>", "start num")
// program.option("--EndNum <StartNum>", "end num")
// program.parse(process.argv);

const provider = new ethers.JsonRpcProvider("localhost:8545")

const main = async () => {
let txCount = 0;
let num = 0;
for (let i = 34130937; i < 34141668; i++) {
let x = await provider.send("eth_getBlockTransactionCountByNumber", [
ethers.toQuantity(i)]);
if (x > txCount) {
num = i;
txCount = x;
}
if ( (i - 34130937) % 1000 === 0) {
await sleep(1)
}
}
console.log(num, txCount);
};

const sleep = async (seconds) => {
console.log('sleep', seconds, 's');
await new Promise((resolve) => setTimeout(resolve, seconds * 1000));
};

main().then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});

0 comments on commit 5c37a35

Please sign in to comment.