Reduce excess block polling when using Web3ProviderEngine

This commit is contained in:
Jacob Evans 2019-03-14 12:26:31 +01:00
parent 4e745489db
commit 8272c7a74e
No known key found for this signature in database
GPG Key ID: 2036DA2ADDFB0842
2 changed files with 13 additions and 5 deletions

View File

@ -31,8 +31,10 @@ export const providerFactory = {
// TODO(bmillman): make this more resilient to infura failures
const rpcUrl = ETHEREUM_NODE_URL_BY_NETWORK[network];
providerEngine.addProvider(new RPCSubprovider(rpcUrl));
// // Start the Provider Engine
providerEngine.start();
// Start the Provider Engine
// HACK: Start the provider without unused block polling
// providerEngine.start();
(providerEngine as any)._ready.go();
return providerEngine;
},
};

View File

@ -125,7 +125,9 @@ export class Blockchain {
return new RPCSubprovider(publicNodeUrl);
});
provider.addProvider(new RedundantSubprovider(rpcSubproviders));
provider.start();
// HACK: Start the provider without unused block polling
// provider.start();
(provider as any)._ready.go();
return [provider, ledgerSubprovider];
} else if (doesInjectedProviderExist && isPublicNodeAvailableForNetworkId) {
// We catch all requests involving a users account and send it to the injectedWeb3
@ -143,7 +145,9 @@ export class Blockchain {
return new RPCSubprovider(publicNodeUrl);
});
provider.addProvider(new RedundantSubprovider(rpcSubproviders));
provider.start();
// HACK: Start the provider without unused block polling
// provider.start();
(provider as any)._ready.go();
return [provider, undefined];
} else if (doesInjectedProviderExist) {
// Since no public node for this network, all requests go to injectedWeb3 instance
@ -159,7 +163,9 @@ export class Blockchain {
return new RPCSubprovider(publicNodeUrl);
});
provider.addProvider(new RedundantSubprovider(rpcSubproviders));
provider.start();
// HACK: Start the provider without unused block polling
// provider.start();
(provider as any)._ready.go();
return [provider, undefined];
}
}