如何配置 Truffle 本身,
或 Truffle 的 HDWalletProvider
使得轮询间隔不同?
我希望我的 Truffle 实例比 JSON-RPC 少一些“喋喋不休”, 当它已经提交交易并正在等待结果时, 从默认值开始减少轮询间隔。
我无法在以下文档中找到此选项:
- https://www.trufflesuite.com/docs/truffle/reference/configuration#networks
- https://github.com/trufflesuite/truffle/tree/master/packages/hdwallet-provider#instantiation
在 truffle-config.js
中,在 networks
中:
testnet: {
provider: () => new HDWalletProvider(
SEED_PHRASE,
'https://localhost:4444/',
),
gasPrice: Math.floor(GAS_PRICE),
networkCheckTimeout: 1e3,
},
最佳答案
修补 @truffle/hdwallet-provider
以添加 pollingInterval
。
现在可以在
truffle@5.1.52
.
修补 truffle
以添加 deploymentPollingInterval
。
现在可以在
truffle@5.1.53
.
例子:
testnet: {
provider: () => new HDWalletProvider({
mnemonic: {
phrase: SEED_PHRASE,
},
providerOrUrl: 'http://localhost:4444',
pollingInterval: 8000,
}),
gasPrice: Math.floor(GAS_PRICE),
networkCheckTimeout: 8000,
deploymentPollingInterval: 8000,
},
未指定时,pollingInterval
和deploymentPollingInterval
的默认值都是4000
;所以上面的示例在轮询 block 时以及在运行 truffle migrate
时具有使它 half 成为 JSON-RPC 上的“chatty”的效果。
关于javascript - 如何在 Truffle 中配置不同的轮询间隔?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64656558/