mirror of
https://gitee.com/BTAJL/repchain.git
synced 2024-12-05 05:08:29 +08:00
在API中增加接口,可以通过API获取当前组网中的共识节点数目和非共识节点数目。
This commit is contained in:
parent
b0cf9baffb
commit
860564e602
@ -58,6 +58,7 @@ object RestActor {
|
||||
|
||||
val contractOperationMode = SystemProfile.getContractOperationMode
|
||||
case object ChainInfo
|
||||
case object NodeNumber
|
||||
|
||||
case class SystemStart(cout: Int)
|
||||
case class SystemStop(from: Int, to: Int)
|
||||
@ -290,5 +291,11 @@ class RestActor(moduleName: String) extends ModuleBase(moduleName) {
|
||||
val cij = JsonFormat.toJson(sr.getBlockChainInfo)
|
||||
sender ! QueryResult(Option(cij))
|
||||
|
||||
case NodeNumber =>
|
||||
val stablenode = pe.getNodeMgr.getStableNodes.size
|
||||
val snode = pe.getNodeMgr.getNodes.size
|
||||
val rs = "{\"consensus nodes\":\""+stablenode+"\",\"nodes\":\""+snode+"\"}"
|
||||
sender ! QueryResult(Option(JsonMethods.parse(string2JsonInput(rs))))
|
||||
|
||||
}
|
||||
}
|
@ -66,7 +66,7 @@ class ChainService(ra: ActorRef)(implicit executionContext: ExecutionContext)
|
||||
implicit val formats = DefaultFormats
|
||||
implicit val timeout = Timeout(20.seconds)
|
||||
|
||||
val route = getBlockChainInfo
|
||||
val route = getBlockChainInfo ~ getNodeNumber
|
||||
|
||||
@ApiOperation(value = "返回块链信息", notes = "", nickname = "getChainInfo", httpMethod = "GET")
|
||||
@ApiResponses(Array(
|
||||
@ -80,6 +80,20 @@ class ChainService(ra: ActorRef)(implicit executionContext: ExecutionContext)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Path("/node")
|
||||
@ApiOperation(value = "返回组网节点数量", notes = "", nickname = "getNodeNumber", httpMethod = "GET")
|
||||
@ApiResponses(Array(
|
||||
new ApiResponse(code = 200, message = "返回组网节点数量", response = classOf[QueryResult])))
|
||||
def getNodeNumber =
|
||||
path("chaininfo" / "node") {
|
||||
get {
|
||||
extractClientIP { ip =>
|
||||
RepLogger.debug(RepLogger.APIAccess_Logger, s"remoteAddr=${ip} get node number")
|
||||
complete { (ra ? NodeNumber).mapTo[QueryResult] }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user