mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Add new streaming subprovider but getting a loop
Regarding #1458 Uses a new streaming subprovider architecture on an experimental branch of StreamProvider: https://github.com/flyswatter/web3-stream-provider/tree/StreamSubprovider
This commit is contained in:
parent
c7fd9f4240
commit
c5432da567
@ -1,5 +1,6 @@
|
||||
const pipe = require('pump')
|
||||
const StreamProvider = require('web3-stream-provider')
|
||||
const StreamSubprovider = require('web3-stream-provider/stream-subprovider')
|
||||
const ProviderEngine = require('web3-provider-engine')
|
||||
const LocalStorageStore = require('obs-store')
|
||||
const ObjectMultiplex = require('./obj-multiplex')
|
||||
const createRandomId = require('./random-id')
|
||||
@ -27,14 +28,21 @@ function MetamaskInpageProvider (connectionStream) {
|
||||
)
|
||||
|
||||
// connect to async provider
|
||||
const asyncProvider = self.asyncProvider = new StreamProvider()
|
||||
const engine = self.asyncProvider = new ProviderEngine()
|
||||
|
||||
const stream = self.stream = new StreamSubprovider()
|
||||
engine.addProvider(stream)
|
||||
|
||||
pipe(
|
||||
asyncProvider,
|
||||
stream,
|
||||
multiStream.createStream('provider'),
|
||||
asyncProvider,
|
||||
stream,
|
||||
(err) => logStreamDisconnectWarning('MetaMask RpcProvider', err)
|
||||
)
|
||||
|
||||
// start polling
|
||||
engine.start()
|
||||
|
||||
self.idMap = {}
|
||||
// handle sendAsync requests via asyncProvider
|
||||
self.sendAsync = function (payload, cb) {
|
||||
@ -46,7 +54,9 @@ function MetamaskInpageProvider (connectionStream) {
|
||||
return message
|
||||
})
|
||||
// forward to asyncProvider
|
||||
asyncProvider.sendAsync(request, function (err, res) {
|
||||
console.log('sending async to engine', request)
|
||||
engine.sendAsync(request, function (err, res) {
|
||||
console.log('send async returned !!', err, res)
|
||||
if (err) return cb(err)
|
||||
// transform messages to original ids
|
||||
eachJsonMessage(res, (message) => {
|
||||
|
Loading…
Reference in New Issue
Block a user