[英]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.