Skip to content

Commit

Permalink
add get message command
Browse files Browse the repository at this point in the history
  • Loading branch information
zyuhel committed Jun 14, 2019
1 parent 210058a commit ae0fe39
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion ops/rpc_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,36 @@ module.exports = function (vorpal) {
}
})
},
getMessage: function (args) {
return new Promise(function (resolve, reject) {
var cmd = 'get message '
var err = null
var data = {success: false}
if (!args.length || args.length > 1) {
err = this.error(-32602)
reject(err)
} else {

cmd += '"' + args[0] + '"'
data = vorpal.execSync(cmd)
data.then(function (data) {
if (data) {
if (data.success === false) {
err = server.error(1, data.error)
} else {
data = data.transaction
}
}
if (err)
reject(err)
else
resolve(data)
}).catch(function (err) {
reject(err)
})
}
})
},
getBlocks: function (args) {
return new Promise(function (resolve, reject) {
var cmd = 'get blocks '
Expand Down Expand Up @@ -377,4 +407,4 @@ module.exports = function (vorpal) {
this.log('JSON-RPC server listening on port ' + config.getRpcConfig().port)

});
};
};

0 comments on commit ae0fe39

Please sign in to comment.