fix conflict in engine
This commit is contained in:
parent
bd0e4a9960
commit
b9472892cb
|
@ -10,6 +10,7 @@ const Watch = require('../pipeline/watch.js');
|
||||||
const LibraryManager = require('../versions/library_manager.js');
|
const LibraryManager = require('../versions/library_manager.js');
|
||||||
const Pipeline = require('../pipeline/pipeline.js');
|
const Pipeline = require('../pipeline/pipeline.js');
|
||||||
const async = require('async');
|
const async = require('async');
|
||||||
|
const Provider = require('./provider');
|
||||||
|
|
||||||
class Engine {
|
class Engine {
|
||||||
constructor(options) {
|
constructor(options) {
|
||||||
|
@ -271,8 +272,8 @@ class Engine {
|
||||||
if (this.web3 === undefined) {
|
if (this.web3 === undefined) {
|
||||||
this.web3 = new Web3();
|
this.web3 = new Web3();
|
||||||
if (this.config.contractsConfig.deployment.type === "rpc") {
|
if (this.config.contractsConfig.deployment.type === "rpc") {
|
||||||
let web3Endpoint = 'http://' + this.config.contractsConfig.deployment.host + ':' + this.config.contractsConfig.deployment.port;
|
const web3Endpoint = 'http://' + this.config.contractsConfig.deployment.host + ':' + this.config.contractsConfig.deployment.port;
|
||||||
this.web3.setProvider(new this.web3.providers.HttpProvider(web3Endpoint));
|
this.web3.setProvider(new Provider(web3Endpoint));
|
||||||
} else {
|
} else {
|
||||||
throw new Error("contracts config error: unknown deployment type " + this.config.contractsConfig.deployment.type);
|
throw new Error("contracts config error: unknown deployment type " + this.config.contractsConfig.deployment.type);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
const ProviderEngine = require('web3-provider-engine');
|
||||||
|
// const ProviderSubprovider = require("web3-provider-engine/subproviders/provider.js");
|
||||||
|
const RpcSubprovider = require('web3-provider-engine/subproviders/rpc.js');
|
||||||
|
|
||||||
|
class Provider {
|
||||||
|
constructor(web3Endpoint) {
|
||||||
|
this.engine = new ProviderEngine();
|
||||||
|
// this.web3 = new Web3(engine);
|
||||||
|
|
||||||
|
this.engine.addProvider(new RpcSubprovider({
|
||||||
|
rpcUrl: web3Endpoint
|
||||||
|
}));
|
||||||
|
|
||||||
|
this.engine.on('block', function (block) {
|
||||||
|
console.log('================================');
|
||||||
|
console.log('BLOCK CHANGED:', '#' + block.number.toString('hex'), '0x' + block.hash.toString('hex'));
|
||||||
|
console.log('================================');
|
||||||
|
});
|
||||||
|
|
||||||
|
// network connectivity error
|
||||||
|
this.engine.on('error', function (err) {
|
||||||
|
// report connectivity errors
|
||||||
|
console.error(err.stack);
|
||||||
|
});
|
||||||
|
this.engine.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
sendAsync() {
|
||||||
|
this.engine.sendAsync.apply(this.engine, arguments);
|
||||||
|
}
|
||||||
|
|
||||||
|
send() {
|
||||||
|
return this.engine.send.apply(this.engine, arguments);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = Provider;
|
|
@ -67,6 +67,7 @@
|
||||||
"url-loader": "^0.6.2",
|
"url-loader": "^0.6.2",
|
||||||
"viz.js": "^1.8.1",
|
"viz.js": "^1.8.1",
|
||||||
"web3": "1.0.0-beta.34",
|
"web3": "1.0.0-beta.34",
|
||||||
|
"web3-provider-engine": "^14.0.5",
|
||||||
"webpack": "^3.10.0",
|
"webpack": "^3.10.0",
|
||||||
"window-size": "^1.1.0"
|
"window-size": "^1.1.0"
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue