并发以太坊帐户创建需要大量时间并冻结以太坊N/W

发布于 2025-02-07 06:21:27 字数 941 浏览 2 评论 0原文

我对以太坊区块链有些新鲜,我想同时创建几个以太坊帐户,如下所示。我正在使用geth来旋转我的以太坊N/W。直到计数为15,延迟并不多。但是,随着我开始增加count,需要几分钟才能真正开始创建帐户。 我知道这与我正在打的异步电话有关。如果我同步这样做,那就没有问题了。

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()

但是,我想了解场景背后的确切发生的事情,以及为什么如果Count变得更大,为什么要花费太多时间。我的实际需求可能会将Count同时创建几个1000个帐户创建。如果我给出这么多的计数,网络冻结和块生成也将停止。即使我终止脚本,它也不会还原。我必须重新启动N/W才能使所有内容都追踪。因此,我也想知道,实现这一目标的最佳方法是什么。

如果有更多信息,请让我知道。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文