add --details option to display paylods for requests and responses

pull/7/head
Iuri Matias 5 years ago
parent 9703013b0e
commit 72d3af4f10
  1. 4
      remix-simulator/bin/ethsim
  2. 8
      remix-simulator/src/provider.js

@ -24,12 +24,14 @@ program
.option('-b, --ip [host]', 'specify host')
.option('-c, --coinbase [coinbase]', 'specify host')
.option('--rpc', 'run rpc server only')
.option('--details', 'display payloads for every requests and their responses')
.parse(process.argv)
const Server = require('../src/server')
const server = new Server({
coinbase: program.coinbase || "0x0000000000000000000000000000000000000000",
rpc: program.rpc
rpc: program.rpc,
logDetails: program.details
})
server.start(program.host || '127.0.0.1', program.port || 8545)

@ -14,6 +14,7 @@ const Transactions = require('./methods/transactions.js')
const generateBlock = require('./genesis.js')
var Provider = function (options) {
this.options = options || {}
this.Accounts = new Accounts()
this.Transactions = new Transactions()
@ -38,8 +39,15 @@ Provider.prototype.sendAsync = function (payload, callback) {
log.info('payload method is ', payload.method)
let method = this.methods[payload.method]
if (this.options.logDetails) {
log.info(payload)
}
if (method) {
return method.call(method, payload, (err, result) => {
if (this.options.logDetails) {
log.info(err)
log.info(result)
}
if (err) {
return callback(err)
}

Loading…
Cancel
Save