Commit 72d3af4f authored by Iuri Matias's avatar Iuri Matias

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

parent 9703013b
...@@ -24,12 +24,14 @@ program ...@@ -24,12 +24,14 @@ program
.option('-b, --ip [host]', 'specify host') .option('-b, --ip [host]', 'specify host')
.option('-c, --coinbase [coinbase]', 'specify host') .option('-c, --coinbase [coinbase]', 'specify host')
.option('--rpc', 'run rpc server only') .option('--rpc', 'run rpc server only')
.option('--details', 'display payloads for every requests and their responses')
.parse(process.argv) .parse(process.argv)
const Server = require('../src/server') const Server = require('../src/server')
const server = new Server({ const server = new Server({
coinbase: program.coinbase || "0x0000000000000000000000000000000000000000", coinbase: program.coinbase || "0x0000000000000000000000000000000000000000",
rpc: program.rpc rpc: program.rpc,
logDetails: program.details
}) })
server.start(program.host || '127.0.0.1', program.port || 8545) server.start(program.host || '127.0.0.1', program.port || 8545)
...@@ -14,6 +14,7 @@ const Transactions = require('./methods/transactions.js') ...@@ -14,6 +14,7 @@ const Transactions = require('./methods/transactions.js')
const generateBlock = require('./genesis.js') const generateBlock = require('./genesis.js')
var Provider = function (options) { var Provider = function (options) {
this.options = options || {}
this.Accounts = new Accounts() this.Accounts = new Accounts()
this.Transactions = new Transactions() this.Transactions = new Transactions()
...@@ -38,8 +39,15 @@ Provider.prototype.sendAsync = function (payload, callback) { ...@@ -38,8 +39,15 @@ Provider.prototype.sendAsync = function (payload, callback) {
log.info('payload method is ', payload.method) log.info('payload method is ', payload.method)
let method = this.methods[payload.method] let method = this.methods[payload.method]
if (this.options.logDetails) {
log.info(payload)
}
if (method) { if (method) {
return method.call(method, payload, (err, result) => { return method.call(method, payload, (err, result) => {
if (this.options.logDetails) {
log.info(err)
log.info(result)
}
if (err) { if (err) {
return callback(err) return callback(err)
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment