[英]Best practice: How to handle 120sec timeout of contract callbacks?
有了Truffle,我们可以很好地打包合同。 但是它具有一个让我头疼的功能:
文档中的示例:
MetaCoin.at(contract_address).then(function(instance) {
coin = instance;
return coin.sendCoin(account_two, 3, {from: account_one});
}).then(function(result) {
// This code block will not be executed until truffle-contract has verified
// the transaction has been processed and it is included in a mined block.
// truffle-contract will error if the transaction hasn't been processed in 120 seconds.
})
这就提出了四个问题:
function(result, error)
)或整个事件( .then( function(result) {...} ).catch(e)
? 我无法在Ganache上进行本地测试。 尤其是问题1让我头疼。
问候
超时仅仅是松露。 网络不会超时,并且在使用web3或类似的包装器开发应用程序时,您只需继续收听,直到tx成为矿工或页面关闭为止。
在web3中进行交易时,即使在被挖掘之前,您也会收到txhash作为响应的一部分。 您可以向用户显示该消息以及未决状态,并可以使用Web3的筛选器在挖掘时为回调设置侦听器,而不会遇到超时问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.