3
info:  Error: Transaction was not mined within 50 blocks, please make sure your transaction was properly send. Be aware that it might still be mined!
    at /opt/bkzcoin_project/bkzcoin-backend/node_modules/web3-core-method/src/index.js:375:45
    at tryCatcher (/opt/bkzcoin_project/bkzcoin-backend/node_modules/web3-core-promievent/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/opt/bkzcoin_project/bkzcoin-backend/node_modules/web3-core-promievent/node_modules/bluebird/js/release/promise.js:497:31)
    at Promise._settlePromise (/opt/bkzcoin_project/bkzcoin-backend/node_modules/web3-core-promievent/node_modules/bluebird/js/release/promise.js:555:18)
    at Promise._settlePromise0 (/opt/bkzcoin_project/bkzcoin-backend/node_modules/web3-core-promievent/node_modules/bluebird/js/release/promise.js:600:10)
    at Promise._settlePromises (/opt/bkzcoin_project/bkzcoin-backend/node_modules/web3-core-promievent/node_modules/bluebird/js/release/promise.js:679:18)
    at Async._drainQueue (/opt/bkzcoin_project/bkzcoin-backend/node_modules/web3-core-promievent/node_modules/bluebird/js/release/async.js:125:16)
    at Async._drainQueues (/opt/bkzcoin_project/bkzcoin-backend/node_modules/web3-core-promievent/node_modules/bluebird/js/release/async.js:135:10)
    at Immediate.Async.drainQueues (/opt/bkzcoin_project/bkzcoin-backend/node_modules/web3-core-promievent/node_modules/bluebird/js/release/async.js:16:14)
    at runCallback (timers.js:800:20)
    at tryOnImmediate (timers.js:762:5)
    at processImmediate [as _immediateCallback] (timers.js:733:5)

在公共测试网和具有 1 个矿工的私有网络的开发过程中,此错误不断重复。前者是有道理的,因为存在竞争条件 b/w 矿工和提高 gas 价格可能会有所帮助,但为什么它发生在我的私人网络上,交易很少且采矿难度低?

我使用 web3jssend方法发送两种类型的交易:

 /** executes contract method by creating transaction
 * @param {string} from - payer address
 * @param {string} to - payee address
 * @param {int} amount - number of tokens
 * @param {string} type - transaction type
 */
transferTokens(from, to, amount, type) {
    if (type === 'transfer_to_admin' || type === 'transfer_from_user') {
        return this.contract.methods.transferFrom(from, to, amount).send({ from })
            .catch((err) => {
                logger.info(err);
                return Promise.reject(err);
            });
    }
    if (type === 'transfer_from_admin') {
        return this.contract.methods.transfer(to, amount).send({ 'from': this.coinbase })
            .catch((error) => {
                logger.info(error);
                return Promise.reject(error);
            });
    }
}

其中transfertransferFrom是 ERC20 标准实现的 Solidity 函数。

任何人都知道如何避免/处理这个错误?

4

0 回答 0