I am bit new on Ethereum Blockchain and I wanted to create several ethereum accounts concurrently something like as shown below. I am using Geth
to spin up my Ethereum n/w. Till the count
is 15, there is not much delay. But as i start increasing the count
, it takes several minutes before it actually starts creating the accounts.
I know it has something to do with the asynchronous calls I am making. If i do it synchronously, there is no issue.
const Web3 = require('web3');
const web3 = new Web3(new Web3.providers.WebsocketProvider("ws://127.0.0.1:8545"));
const generateAccount = () => {
const count = 30;
let promises = []
for (let i=0; i<count; i++) {
promises.push(web3.eth.personal.newAccount("Hello@12345"));
}
Promise.allSettled(promises).then(
status => {
console.log(status)
process.exit(0)
}
).catch(
err => {
console.log(err)
process.exit(1)
}
)
}
generateAccount()
But, I want to understand what exactly happening behind the scene and why it's taking so much time if the count
gets bigger. My actual requirement might take the count
to several 1000s of account creation concurrently. If I am giving that much count, the network freezes and block generation is also stopped. Even if I terminate the script, it doesn't restores. I have to restart the n/w to bring everything back to track. So i also want to know, what's the best approach on achieving this.
Please do let me know in case of more information.