aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkumavis <aaron@kumavis.me>2016-03-11 05:04:45 +0800
committerkumavis <aaron@kumavis.me>2016-03-11 05:04:45 +0800
commit1ffc98917d82620b33fc1d2005bf3d2d31db47cd (patch)
tree1a92c838d45381e5110d0fbf51f0ce0231cde6d0
parent18c4f18c71d479038bf11f34edf3e6899246724b (diff)
downloadtangerine-wallet-browser-1ffc98917d82620b33fc1d2005bf3d2d31db47cd.tar
tangerine-wallet-browser-1ffc98917d82620b33fc1d2005bf3d2d31db47cd.tar.gz
tangerine-wallet-browser-1ffc98917d82620b33fc1d2005bf3d2d31db47cd.tar.bz2
tangerine-wallet-browser-1ffc98917d82620b33fc1d2005bf3d2d31db47cd.tar.lz
tangerine-wallet-browser-1ffc98917d82620b33fc1d2005bf3d2d31db47cd.tar.xz
tangerine-wallet-browser-1ffc98917d82620b33fc1d2005bf3d2d31db47cd.tar.zst
tangerine-wallet-browser-1ffc98917d82620b33fc1d2005bf3d2d31db47cd.zip
plumbing - fix rpc feedback loop bug
-rw-r--r--app/scripts/background.js17
-rw-r--r--package.json1
2 files changed, 9 insertions, 9 deletions
diff --git a/app/scripts/background.js b/app/scripts/background.js
index 864cd04be..aa74cb921 100644
--- a/app/scripts/background.js
+++ b/app/scripts/background.js
@@ -2,6 +2,7 @@ const Dnode = require('dnode')
const Multiplex = require('multiplex')
const Through = require('through2')
const eos = require('end-of-stream')
+const combineStreams = require('pumpify')
const extend = require('xtend')
const EthStore = require('eth-store')
const PortStream = require('./lib/port-stream.js')
@@ -28,10 +29,6 @@ function connectRemote(remotePort){
}
function handleEthRpcRequestStream(stream){
- // portStream
- stream.on('data', function(data){
- console.log(data)
- })
stream.on('data', onRpcRequest.bind(null, stream))
}
@@ -76,7 +73,7 @@ function onRpcRequest(remoteStream, payload){
// provider engine errors are included in response objects
// if (!payload.isMetamaskInternal) console.log('MetaMaskPlugin - RPC complete:', payload, '->', response)
try {
- remoteStream.push(response)
+ remoteStream.write(response)
} catch (err) {
console.error(err)
}
@@ -101,10 +98,12 @@ function handleInternalCommunication(portStream){
mx.destroy()
})
var dnodeStream = mx.createSharedStream('dnode')
- var providerStream =
- jsonStringifyStream()
- .pipe(mx.createSharedStream('provider'))
- .pipe(jsonParseStream())
+ var providerStream = combineStreams(
+ jsonStringifyStream(),
+ mx.createSharedStream('provider'),
+ jsonParseStream()
+ )
+
linkDnode(dnodeStream)
handleEthRpcRequestStream(providerStream)
}
diff --git a/package.json b/package.json
index 18fb746e4..9b8c5c1d9 100644
--- a/package.json
+++ b/package.json
@@ -20,6 +20,7 @@
"inject-css": "^0.1.1",
"metamask-ui": "^1.5.0",
"multiplex": "^6.7.0",
+ "pumpify": "^1.3.4",
"readable-stream": "^2.0.5",
"through2": "^2.0.1",
"web3": "^0.15.1",