我应该在我的 API 中同步进行 Solana 交易吗?

Should I do Solana transactions synchronously in my apis?

所以我知道,与大多数更去中心化的区块链相比,Solana 速度更快。

不过,我的问题是我是否应该从队列中异步执行我的事务 - 这样我就可以在出现问题时重试失败等等

这会变得更加复杂,例如,如果我使用 metaplex 创建具有关联元数据等的令牌,因为它涉及 2 个事务:1 个用于创建令牌,另一个用于为令牌创建令牌元数据

绝对鼓励您酌情重试交易。这是 Solana Cookbook 的摘录,其中给出了重试的 TLDR:

  • RPC nodes will attempt to rebroadcast transactions using a generic algorithm
  • Application developers can implement their own custom rebroadcasting logic
  • Developers should take advantage of the maxRetries parameter on the sendTransaction JSON-RPC method
  • Developers should enable preflight checks to raise errors before transactions are submitted
  • Before re-signing any transaction, it is very important to ensure that the initial transaction’s blockhash has expired

您可以在 https://solanacookbook.com/guides/retrying-transactions.html

阅读完整的源代码