Skip to content

Commit

Permalink
Merge pull request #1242 from ainblockchain/bugfix/platfowner/bugfix
Browse files Browse the repository at this point in the history
Fix json rpc consensus apis
  • Loading branch information
platfowner committed Feb 8, 2024
2 parents 07bb948 + 8a415da commit 86a6a91
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 4 additions & 2 deletions json_rpc/consensus.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,22 @@ const {
TrafficEventTypes,
trafficStatsManager,
} = require('../common/constants');
const PathUtil = require('../common/path-util');
const JsonRpcUtil = require('./json-rpc-util');
const { JSON_RPC_METHODS } = require('./constants');

module.exports = function getBlockApis(node) {
module.exports = function getConsensusApis(node) {
return {
[JSON_RPC_METHODS.AIN_GET_VALIDATOR_INFO]: function(args, done) {
const beginTime = Date.now();
const addr = args.address;
const isWhitelisted = node.db.getValue(PathUtil.getConsensusProposerWhitelistAddrPath(addr)) || false;
const stake = node.db.getValue(PathUtil.getServiceAccountBalancePath(addr)) || 0;
const stake = node.db.getValue(PathUtil.getConsensusStakingAccountBalancePath(addr)) || 0;
const latency = Date.now() - beginTime;
trafficStatsManager.addEvent(TrafficEventTypes.JSON_RPC_GET, latency);
done(null, JsonRpcUtil.addProtocolVersion({
result: {
address: addr,
isWhitelisted,
stake,
}
Expand Down
2 changes: 2 additions & 0 deletions json_rpc/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const getAccountApis = require('./account');
const getAppApis = require('./app');
const getAdminApis = require('./admin');
const getBlockApis = require('./block');
const getConsensusApis = require('./consensus');
const getDatabaseApis = require('./database');
const getEventHandlerApis = require('./event-handler');
const getNetworkApis = require('./network');
Expand Down Expand Up @@ -36,6 +37,7 @@ module.exports = function getApis(node, p2pServer, minProtocolVersion, maxProtoc
...getAccountApis(node),
...getAppApis(node),
...getBlockApis(node),
...getConsensusApis(node),
...getDatabaseApis(node),
...getNetworkApis(node, p2pServer),
...getTransactionApis(node, p2pServer),
Expand Down

0 comments on commit 86a6a91

Please sign in to comment.